Re: Saving Image in mySQL

Toby Hart Dyke <[email protected]>
Newsgroups gmane.comp.php.database
Message-ID <[email protected]>
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);
>          
>


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.