Solved

Upload temporary file name in PHP

Posted on 2008-06-17
5
749 Views
Last Modified: 2013-12-13
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.
0
Comment
Question by:mpiaser
5 Comments
 
LVL 49

Expert Comment

by:Roonaan
ID: 21804515
You can't. The php is only executed after the upload has been completed.
0
 
LVL 48

Expert Comment

by:hernst42
ID: 21805236
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
0
 
LVL 36

Expert Comment

by:Loganathan Natarajan
ID: 21811951
>> 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
0
 

Author Comment

by:mpiaser
ID: 21811985
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.
0
 

Accepted Solution

by:
mpiaser earned 0 total points
ID: 22777129
How do I get this question closed?  I solved this issue myself.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

895 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now