faqts : Computers : Programming : Languages : PHP : Common Problems : File Uploading

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

1059 of 1669 people (63%) answered Yes
Recently 3 of 10 people (30%) answered Yes

Entry

How do I find the file I just uploaded to the webserver and load it?

Feb 10th, 2000 08:49
Matt Gregory, Gary Chu,


No matter where the file is uploaded, php will store certain variables 
for you containing information about the file.  The full path and 
filename are located in the variable with the same name as your file 
form field.  Let's say you called your file upload filed "Picture" and 
that your Apache temp directory is /inetpub/tmp/.  In your script, the 
variable $Picture will contain "/inetpub/tmp/1002.tmp" where 1002.tmp 
is the temporary name of the file uploaded.  The variable $Picture_name 
will contain the origional file name.  Performing a copy
($Picture, "./images/" . $Picture_name); will put the image, proper 
name and all, in the images directory under the script root.  If the 
security on the server will not allow you to use the copy command, try 
the file commmands to create and write a new file: (fopen, fread, 
fwrite).  If the server security will not allow that command either, 
try putting the images into a blob or binary field in your database.