Does anyone know the proper method for inserting an image(*.jpg or
*.gif) into a MySql database blob field?  I am recieving the file via an
html form with the usual enctype for this and <input type=file>
parameters.  I can save it as just a regular file and then display it
fine on the page, but no way can I update the database with this...and
have tried everything imaginable...surely this is done everyday and is
quite simple.

code snippet below - and yes, I am a php beginner...ASP by day and
trying to learn
PHP by night..
$photo  = fopen($txtImage, "r");
$filecontents = fread($photo, filesize($txtImage));
echo "<br>";
echo "<img src='$photo'>";
$anotherfile = fopen("/www/htdocs/Survey/$thisfile", "a+");
fputs($anotherfile, $filecontents);
echo "<br>";
echo "<img src='$anotherfile'>";
echo "<br>";
echo $photo;
echo "<br><br><center>";
echo "<img src='$thisfile'>";
$crapola = "101010101";
echo "<br><br><center>";

 $connection = mysql_connect("mysql.iticom.net","fractalv","fw348vnj")
or die ("crap!");
 $db = mysql_select_db("fractalv", $connection) or die ("db");
 $sql = "INSERT INTO Images (Image,
ImageType,ImageGallery,ImageLink,ThumbnailLink) VALUES
('$filecontents','$txtImageType', '$txtImageGallery', '$txtImageLink',
 $sql_result = mysql_query($sql,$connection) or die ("could not insert
into DB");

thanks in advance for absolutley any ideas!

Phil J.


PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to