Re: Saving Image in mySQL

From: Date: Wed, 20 Mar 2013 12:43:22 +0000
Subject: Re: Saving Image in mySQL
References: 1  Groups: php.db 
Request: Send a blank email to php-db+get-48706@lists.php.net to get a copy of this message
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: file_get_contents($_FILES['file']['tmp_name']) Toby 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"], PDO::PARAM_STR);
         $stmt->bindValue(':image_size', $_FILES["file"]["size"], PDO::PARAM_INT);
         $stmt->bindValue(':image_name', $_FILES["file"]["name"], PDO::PARAM_STR);
         $stmt->bindValue(':image', $file, PDO::PARAM_STR);
         


« previous php.db (#48706) next »