PHP Forums Archive

multi upload file

Tags: file upload, file name

francescoflore posted on 2009-11-18 14:45:19 #

Hello,

I am using the multi-upload file which works fine. But I know discovered that if a user uplaods a file with spaces in its name, such as image 1.jpg. It still uploads it but then it doesn't render it into the browser because of the space.

I have tried the $multi_upload->set_file_name = true; but it does not do what expected or I am missing something?

If this is not what I need is there a way to make sure that picture uploaded are not stored with empty spaces?

Many many thanks in advance for your help. Francesco

Comments / discussions

Olaf posted on 2009-11-18 14:49:41 #

The class has an option to rename the file which should work. Maybe that you store the original filename in a database?

francescoflore posted on 2009-11-18 14:55:21 #

I have activated the rename(got rid of //) and yes the name is stored in database.

It doesn't seem to rename the file. Tried few times but still the name stays the same.

Olaf posted on 2009-11-18 14:57:35 #

Which variable do you store in your database? do you checked database/upload example file?

francescoflore posted on 2009-11-18 15:04:29 #

Hi Olaf,

Just noticed one thing: If I use $multi_upload->set_file_name = true; it enters the name into the database but it does not upload the file to folder.

If I not use it //$multi_upload->set_file_name = true; then it all works fine until of course I upload a file with empty spaces which are still uploaded to database and folder but not rendered in browser because of space.

Sorry I am not sure if I am missing some stupid thing here. Apologies for that.

Olaf posted on 2009-11-18 15:10:36 #

What is the variable name you store in the database?

maybe you can post the part with the query here?

francescoflore posted on 2009-11-18 15:16:21 #

I have just discovered one more thing. with set on it uploads the file name to database and it uploades to folder but while in the database the nae stay wiht spaces into the forlder the underscore added instead to spaces.

Is it this you are asking?

($_FILES['upload']['name'][0], "text"),
...

francescoflore posted on 2009-11-18 15:30:34 #

Hi Olaf,

Sorry this thing is becoming quite complicated. I have now found out that it does change the name but it stores the new name (random number) only into the folder but into the database stores the original name. That is why it does not show. Sorry about this.

Olaf posted on 2009-11-18 18:46:45 #

Right this is what you're doing wrong in your script you need to store the new name not the old name :)

check the example I have posted for you before: PHP multi upload script.

This variable is mentioned in almost ALL example files:

$error .= 'File "'.$my_upload->file_copy.'" uploaded';