cant find uploaded file in /tmp.

cant find uploaded file in /tmp.

am 03.10.2010 19:53:38 von aprekates

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.

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: cant find uploaded file in /tmp.

am 03.10.2010 20:16:02 von Ashley Sheridan

--=-O2h63rNkAaYa9a51CxLX
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: 7bit

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



--=-O2h63rNkAaYa9a51CxLX--

Re: cant find uploaded file in /tmp.

am 04.10.2010 16:20:01 von TedD

At 7:16 PM +0100 10/3/10, Ashley Sheridan wrote:
>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


Ash:

Thanks for the plug. The code is pretty simple.

If the "simple script" the OP used did indeed move the file to the
tmp directory, then it should be there for him to see.

I suspect that: 1) the upload script is not working properly; 2) or
the OP needs to refresh his IDE to reflect changes made to the server.

Cheers,

tedd

--
-------
http://sperling.com/

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php