PHP File Upload, files disappearing from /tmp before move_uploaded_files

Posted by Bowen on Stack Overflow See other posts from Stack Overflow or by Bowen
Published on 2009-11-30T12:35:08Z Indexed on 2010/04/06 21:13 UTC
Read the original article Hit count: 255

Filed under:
|
|
|

Hi,

I have a very basic upload script, probably lifted straight off the php.net/move_upload_files function page.

move_uploaded_file() is failed because it cannot find the tmp file in the tmp folder. But I KNOW that it is being put there, but is removed before move_upload_file() can deal with it in my script. I know it is being put there since I can see a file in there when a large file is being posted to the server.

Also $_FILEScontains correct details for the file I have just uploaded.

Had anyone have any idea why the temporary file is being removed from /tmp before I have a chance to handle it?

Here is the basic code that I am using.

if(move_uploaded_file($_FILES['userfile']['tmp_name'], $upload_file))
{
    $result['error'] = 'false';
    $result['file_loc'] = $upload_file;
}
else
{
    $result['error'] = 'true';
}

The output of print_r($_FILES) looks like

[userfile] => Array
(
    [name] => switchsolo.png
    [type] => image/png
    [tmp_name] => /tmp/phpIyKRl5
    [error] => 0
    [size] => 6690
)

But /tmp/phpIyKRl5 simply isn't there.

© Stack Overflow or respective owner

Related posts about php

Related posts about file