Re: Insert image into MySQL

From: Date: Thu, 14 Feb 2002 15:25:41 +0000
Subject: Re: Insert image into MySQL
References: 1  Groups: php.windows 
Request: Send a blank email to php-windows+get-12083@lists.php.net to get a copy of this message
Can you just insert the location of the file instead of the whole image into the database? is there a reason why you are inserting into the database? How many images do you have or projected to have? "Sichta Daniel" <Daniel.Sichta@swh.sk> wrote in message news:29BDD4F529FCD311B631009027357C4E04D97B70@btss103a.swh.sk... Hi, cfg: w2k, Apache 1.3, php4.11, Mysql 3-23-40-max-nt I'm using following code to insert images (gif, jpg) into table. Everything worked fine until I switch to php4.11. Now this code is inserting only image header or something similar. BTW: pct_data is longblob !!! Thank you for any help !! Dan <? if ($submit) { mysql_connect( "****", "*****", "********"); mysql_select_db( "****"); $data = addslashes(fread(fopen($form_data, "r"), filesize($form_data))); $size = GetImageSize ($form_data); $result = mysql_query("INSERT INTO pictures VALUES (0,'$data','$form_data_type','$size[0]','$size[1]')"); $id = mysql_insert_id(); print "<p>this file has the following database id: <b>$id</b>"; mysql_close(); } else { ?> <form method="POST" action="<?$PHP_SELF;?>" enctype="multipart/form-data"> <input type="hidden" name="max_file_size" value="1000000"> <br>Meno súboru :<br> <input type="file" name="form_data" size="40"> <p><input type="submit" name="submit" value="submit"> </form> <? } ?>

« previous php.windows (#12083) next »