From: Date: April 27 1999 4:06pm Subject: Re: [PHP3][MySQL] Upload file into database List-Archive: http://lists.mysql.com/mysql/2474 Message-Id: <3725C461.B47365BB@PacWan.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit John Craig wrote: > don't know if it's the best way to do it, but seems to work OK. > > $fp = fopen('big.file.jpg', 'r'); > $jpg = fread($fp, filesize('big.file.jpg)); > fclose($fp); > $db->query("update table set blob_field = '".base64_encode($jpg)."' where > ... > > JC Ok Thanks, but is it possible to combine this with the upload method in order to upload directly a file from outside into the blob ? the upload method is : */ /* February-ish 1999 */ /* Use it however you want. I'm not responsible for what you do with it. */ /* how many upload slots? */ define( "UPLOAD_SLOTS", 5); /* where to move the uploaded file(s) to? */ define( "INCOMING", "/home/ronny/incoming/"); if($REQUEST_METHOD!= "POST") { /* generate form */ echo "
\n"; for($i=1; $i<=UPLOAD_SLOTS; $i++) { echo "
\n"; } echo "
\n"; } else { /* handle uploads */ $noinput = true; for($i=1; $noinput && ($i<=UPLOAD_SLOTS); $i++) { if(${ "infile".$i}!= "none") $noinput=false; } if($noinput) { echo "error uploading. create 150MB coredump instead?"; exit(); } for($i=1; $i<=UPLOAD_SLOTS; $i++) { if(${ "infile".$i}!= "none" && copy(${ "infile".$i}, INCOMING.${ "infile".$i. "_name"}) && unlink(${ "infile".$i})) { echo ${ "infile".$i. "_name"}. " uploaded
"; } } } /* else */ ?> Thanks, Philippe.