How can I get the contents of a document and upload to a Mysql blob field using PHP? -
when run code, , $testpage alphameric string, uploaded perfectly. however, when $testpage defined using file_get_contents(...), not upload @ all.
<? ... ... mysql_connect(localhost,$username,$password); mysql_select_db($database) or die("unable select database"); $testpage = file_get_contents('http://us3.php.net/manual/en/function.file-get-contents.php'); $testpage = mysql_real_escape_string($testpage); mysql_query("insert thetable(description,document) values('php webpage test','$testpage')"); mysql_close; ?>
i understood php docs file_get_contents(...) preferred way convert files string stored in binary field. aware there more security issues have deal first want able raw upload , proceed there. there reason why should not work , if so, best way this? or missing something?
thanks!
r
you need escape string.
$testpage = file_get_contents(..); $testpage = mysql_real_escape_string($testpage); mysql_query("insert thetable(description,document) values('php webpage test','$testpage')");
Comments
Post a Comment