The database I have created for storing images has a field called binary_junk which is of type "BLOB" but its still not working...
TIA, sandeep ----- Original Message ----- From: "AJDIN BRANDIC" <[EMAIL PROTECTED]> To: "Sandeep Murthy" <[EMAIL PROTECTED]> Cc: <[EMAIL PROTECTED]> Sent: Wednesday, October 03, 2001 5:23 PM Subject: Re: inserting images > I have never done it but have seen posts on this topic. From what I > understand you need to create a BLOB field in your DB (MySQL) then upload > file to your server, read it with fopen (or ...) into a variable then > insert that variable into the BLOB field you have in your DB. > > Hope I am right here? > > Regards > > Ajdin > > On Wed, 3 Oct 2001, Sandeep Murthy wrote: > > > hi all, > > > > I have been trying to insert images into my mysql database thru PHP for the > > past 2 days without any luck.. After having tried various combinations of > > queries, I gave up.. > > > > Wud be grateful if anyone can post a query for inserting images in to my > > database.. > > > > TIA, > > Sandeep > > > > > > This is what i hv tried: > > > > <HTML> > > <HEAD> > > <TITLE>Binary Data Insert Form</TITLE> > > </HEAD> > > > > <BODY> > > <H1>Upload a File:</H1> > > > > <FORM enctype="multipart/form-data" > > method="post" action="do_insert.php"> > > <INPUT type="file" name="img1" size="30"> > > <INPUT type="submit" name="submit" > > value="Use this File"> > > > > </FORM> > > </BODY> > > </HTML> > > > > __________________________________________________________ > > <? > > if (!isset($img1)) { > > header("Location: insert_file.html"); > > exit; > > } > > > > $db = @mysql_connect("localhost","root","sandeep") or > > die("Can't connect to server."); > > @mysql_select_db("yourDB", $db) or > > die("Can't select database."); > > > > $binary_junk = addslashes (fread(fopen($img1, "r"), filesize($img1))); > > $insert_data = "INSERT INTO > > images (img_id, binary_junk, filename, filesize, filetype) > > VALUES ('1', '$binary_junk', '$img1_name', '$img1_size', '$img1_type')"; > > > > @mysql_query($insert_data) or > > > > The error is occuring here , am getting a "couldnt insert data error" > > > > die("Couldn't insert data."); > > > > ?> > > > > > > > > --------------------------------------------------------------------- > > Before posting, please check: > > http://www.mysql.com/manual.php (the manual) > > http://lists.mysql.com/ (the list archive) > > > > To request this thread, e-mail <[EMAIL PROTECTED]> > > To unsubscribe, e-mail <[EMAIL PROTECTED]> > > Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php > > > > > > --------------------------------------------------------------------- > Before posting, please check: > http://www.mysql.com/manual.php (the manual) > http://lists.mysql.com/ (the list archive) > > To request this thread, e-mail <[EMAIL PROTECTED]> > To unsubscribe, e-mail <[EMAIL PROTECTED]> > Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php > --------------------------------------------------------------------- Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive) To request this thread, e-mail <[EMAIL PROTECTED]> To unsubscribe, e-mail <[EMAIL PROTECTED]> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php