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 :
<?php
/* Handle multiple file upload easily */
/* by Ronny Haryanto <giant@stripped> */
/* 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 "<form enctype=\"multipart/form-data\" method=post>\n";
for($i=1; $i<=UPLOAD_SLOTS; $i++)
{
echo "<input type=file name=infile$i><br>\n";
}
echo "<input type=submit value=upload></form>\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<br>";
}
}
} /* else */
?>
Thanks,
Philippe.