> <problem>
> How do I insert files inte BLOBs?
> </problem>
Tomas,
I use this PHP function to insert ASCII files into BLOBs. I think it would
also work for binary files but I have not tested it. Please note that there
are other (perhaps better) ways to insert into BLOBs but this works for me.
Good luck,
Philip
---------------------- code starts here ----------------------
function RecordFile($pathname, $filename) {
$filesize = filesize($pathname . "/" . $filename);
$fp = fopen($pathname . "/" . $filename, "r");
$content = fread($fp, $filesize);
fclose($fp);
$content = addslashes($content);
$filename = addslashes($filename);
$pathname = addslashes($pathname);
$s = "insert into files (path, name, size, content) values (";
$s = $s . "'" . $pathname . "', ";
$s = $s . "'" . $filename . "', ";
$s = $s . "'" . $filesize . "', ";
$s = $s . "'" . $content . "'";
$s = $s . ")";
if (mysql_query($s) == false) {
lprint("Query failed: " . $s);
lprint(mysql_error());
}
}
---------------------- code ends here ----------------------
---------------------------------------------------------------------
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