Page 1 of 2

Specify where to store upload files

Posted: Thu Sep 02, 2004 12:35 pm
by ljCharlie
When uploading files to server, how do I specify which folder to store the files on the server?

ljCharlie

Posted: Thu Sep 02, 2004 12:37 pm
by feyd
the files are first stored in the temporary directories.. you then move them where you want them.

Posted: Thu Sep 02, 2004 12:41 pm
by m3mn0n
Indeed.

Google: [google]php file uploading snippet[/google]

Posted: Thu Sep 02, 2004 12:42 pm
by ljCharlie
So then there is no way to specify the location where the file will be store then, correct?

ljCharlie

Posted: Thu Sep 02, 2004 12:43 pm
by feyd
you can specify it, however you do not control the filename it'll get saved as initially.

Posted: Thu Sep 02, 2004 12:45 pm
by m3mn0n
Yeah. You can specify a PHP temporary directory. But like feyd mentioned, it's best to have them stored in whatever temp directory PHP uses, and then move it to where ever you want.

Posted: Thu Sep 02, 2004 12:45 pm
by ljCharlie
Okay. How do I specify the location? And can you explain the part about I do not control the file name?

Thank you,

ljCharlie

Posted: Thu Sep 02, 2004 12:45 pm
by m3mn0n
Sami wrote:Google: [google]php file uploading snippet[/google]
Check out some samples from that search. :)

Posted: Thu Sep 02, 2004 12:47 pm
by m3mn0n
Oh and the filename is a randomly generated name by PHP.

Upload a file and run this script:

Code: Select all

echo '<pre>';
   print_r ( $_FILES );
echo '</pre>';
And you will see it in action for yourself.

Posted: Thu Sep 02, 2004 1:11 pm
by ljCharlie
What sort of permission should the folder be having to be able to receive the file? Currently the folder is set to 762 but I still error about permission denied.

ljCharlie

Posted: Thu Sep 02, 2004 1:13 pm
by ol4pr0
i believe they will need them all. 777 ( not sure hto.. but that most certenly will work )

Posted: Thu Sep 02, 2004 1:14 pm
by ljCharlie
Will this be a security issue if it is set to 777?

ljCharlie

Posted: Thu Sep 02, 2004 1:19 pm
by ol4pr0
Well u can have apache be set as owner of that folder, that would limit it somewhat, but what kind of problems do u expect. Or are u allowing exe files being uploaded on a windows server ? That is a security issue lol.

Posted: Thu Sep 02, 2004 1:21 pm
by ljCharlie
Okay, here's another thing. How do I limit to only upload images such as jpeg file format?

ljCharlie

Posted: Thu Sep 02, 2004 1:23 pm
by feyd
you have to check the type of the file. Do not rely on the filename or mime-type sent by the browser, both can be faked. Check the actual type of the file using [php_man]getimagesize[/php_man] for more details.. I've posted many many times about this, so search for those.