Re: Saving Image in mySQL

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 3/20/2013 8:43 AM, Toby Hart Dyke wrote:

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);


And in doing this your destination would then be the final resting place for the image(s), with the pointer to each stored in your table record for that image. :)

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux