You're right - you're pulling $file out of thin air. Once uploaded, the file is stored in $_FILES['file']['tmp_name'], and you need to manually read the data into $file yourself. Something like:



On 3/19/2013 8:15 PM, Ron Piggott wrote:
Hi All
I don’t understand how to save an image to a mySQL table based on the following 
form. I am trying to do this using Prepared Statements.  All the fields except 
the image file itself save in the database.  Right now I have $file as the 
variable when binding the values.  What should it be?  Ron

# bind variables

         $stmt->bindValue(':caption', 'Test Caption', PDO::PARAM_STR);
         $stmt->bindValue(':image_type', $_FILES["file"]["type"], 
         $stmt->bindValue(':image_size', $_FILES["file"]["size"], 
         $stmt->bindValue(':image_name', $_FILES["file"]["name"], 
         $stmt->bindValue(':image', $file, PDO::PARAM_STR);

PHP Database Mailing List (
To unsubscribe, visit:

Reply via email to