Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

UPLOADING FILES

Status
Not open for further replies.

kingdna1980

Technical User
Apr 16, 2005
2
GB
I am trying to update and store in mysql the file name of an uploaded file stored within the array
$_FILES['userfile']['name'].
However if you try and update with $_FILES['userfile']['name']... You aren't allowed.
If try and update mysql using... print $_FILES['userfile']['name'] you end up updating the filename as the nos 1 instead of the filename.
I've tried creating a new variable called $fname = print $_FILES['userfile']['name'] and tried to update using $fname but this still doesn't work. It also doesn't allow you to echo $_FILES['userfile']['name']. There must be a way of me being able to access the information witin the array $_FILES['userfile']['name'] and then passing this up to mysql. If anyone can help that would be awesome. Many thanks.

 
Thanks a lot dude, but i've worked it out.i needed to simply change...

$file_name = $_FILES["Image"]["name"];

$sql = "UPDATE tablename
SET image_name=('{$file_name}')";

//I had been writing the final line of code as...

SET image_name=$file_name";

// By adding all the ('{ seems to have done the trick
//I don't really know why this works but it does, and thats good enough for an amateur like me!!! if you know then i am eager to learn... Thanks j
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top