Re: cant find uploaded file in /tmp.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sun, 2010-10-03 at 20:53 +0300, Prekates Alexandros wrote:

> Hi to the list.
> 
> Trying to test php upload i used a very simple scrip.
> I managed to upload files but i dont understand why the dont
> stay in the /tmp dir where the initialy are put even if i dont move them
> to another dir.
> 
> alex.
> 


Files are put into the /tmp directory by Apache, before PHP is even
aware of them. Unless you create a copy of the file, then Apache will
clean it up after your script has run (or at least it's supposed to, but
sometimes /tmp becomes a little cluttered with crud)

The best thing to do is to use move_uploaded_file to move the file to
someplace, and give the file a new name (or keep the same one and add an
extension if you want to ensure the file is given a unique name in the
directory you're putting it into)

There are lots of different scripts on the manual page for
move_uploaded_file if you're feeling a little stuck. As a safety
precaution, it's considered good practice to copy the file to a location
outside of your document root. So if your document root
is /var/www/html/ then maybe put the file in /var/www/user_files/ . This
means that people can't use your website to upload their own scripts and
gain access to your server, although it does mean you need to find an
alternative way to serve up that file if you need, but that is quite
easy, and there are lots of example scripts about for that if you need;
many people on the list have written their own, and Tedd most likely has
an example somewhere too!

Thanks,
Ash
http://www.ashleysheridan.co.uk



[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux