Reputation: 10971
I am using XAMPP on Windows. By printing $_FILES["file"]["tmp_name"]
, it seems that the temporary file was saved at C:\xampp\tmp\phpABCD.tmp. But I cannot see it on the filesystem of the server. However, the file can be moved or copied via move_uploaded_file()
, rename()
, or copy()
. So where does PHP actually save temporary files during uploading?
Upvotes: 30
Views: 68960
Reputation: 50
IF you are asking the file location then it depend on the setting of server. but if you are asking whether it saved first in local system or in server. then answer is it save in temp folder in server.
Upvotes: -1
Reputation: 1
Note that the file is saved binary in $_FILES["file"]["tmp_name"]
, so you may open it maybe with file_get_contents
if it is an image or something like this...
Upvotes: 0
Reputation: 10466
You can check where php is currently saving your temp files $_FILES["file"]["tmp_name"]
by printing
sys_get_temp_dir()
Upvotes: 12
Reputation: 51
Use move_uploaded_file(file, path)
, specify the file and the path where you want to store the file.
A copy of that file is created and gets stored.
Upvotes: 5
Reputation: 11395
from http://www.php.net/manual/en/features.file-upload.php#93602, "...the uploaded file will inherit the permissions of the directory specified in the directive upload_tmp_dir
of php.ini
. If this directive isn't set, the default of C:\Windows\Temp is used..."
Upvotes: 2
Reputation: 388333
php stores all temporary files, that includes uploaded files, in the temporary files directory as specified in the php.ini. Note that for uploads, those files might be removed as soon as the script the file was uploaded to was terminated (so unless you delay that script, you probably won't see the uploaded file). Another reason might be that the file is simply hidden on the file system.
So if you want to see the file, you might want to make sure you see all hidden files in the explorer and delay the script as long as you need to find the file.
Upvotes: 4
Reputation: 48304
It saves it at the path specified in $_FILES["file"]["tmp_name"]
, but deletes it after the script is done executing. It's up to you to move the file elsewhere if you want to preserve it.
Upvotes: 61
Reputation: 12870
Its specified in upload_tmp_dir
in your php.ini file. It is deleted by the system automatically after use.
Upvotes: 24