Link to home
Start Free TrialLog in
Avatar of mpiaser
mpiaser

asked on

Upload temporary file name in PHP

When I do an HTML upload, controlled by PHP, once it is complete I can get the temporary file name by looking at [tmp_name] => C:\Program Files\PHP\uploadtemp\php5A0D.tmp of $_FILES

I want to either be able to control the tmp_name or know what the name is before the upload is complete.
Avatar of Roonaan
Roonaan
Flag of Netherlands image

You can't. The php is only executed after the upload has been completed.
The name of the file the user uploaded is stored in ['name']. You can also check the filename that should be uploaded with Javascript on the client side
>> I want to either be able to control the tmp_name or know what the name is before the upload is complete.

I think, it might be stored on the server in the temporary folder where you have configured the tmp foldre, just get it with,

$_FILES["file"]["tmp_name"] - the name of the temporary copy of the file stored on the server

print the name using $_FILES["file"]["tmp_name"]

and see this available on you temp dir

ref. http://www.tizag.com/phpT/fileupload.php
Avatar of mpiaser
mpiaser

ASKER

it is there but it is not populated until AFTER the upload has been completed.  I have found a way to code around this situation by looking in the temp directory before launching the upload and then looking again one the upload starts - by comparing the two I know which file(s) were created (that is the temporary file containing the upload data).  It isn't a perfect approach as the code can get mixed up if two uploads are started at the same time...but it is better than any alternative I've been able to come up with.

Might as well close this question.
ASKER CERTIFIED SOLUTION
Avatar of mpiaser
mpiaser

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial