0
我已將圖像保存爲我的數據庫中的BLOB,現在我想提取圖像並將其保存到目錄中。如何提取BLOB圖像並將其保存在使用PHP的目錄中?
到目前爲止,我可以使用以下代碼查看BLOB圖像。
<?
$con = mysql_connect("genetech002" , "username" , "mypass");
$db = mysql_select_db("Mydatabase", $con);
$sql = "SELECT * FROM hs_hr_emp_picture WHERE emp_number = 5";
$result = mysql_query($sql) or die(mysql_error());
$row = mysql_fetch_array($result);
?>
我可以在執行上面的腳本後,看到我的瀏覽器中的圖像,但現在我想保存在一個目錄這個圖像(我的服務器上)。
是file_put_contents()一個php函數嗎? – 2013-04-23 08:17:25
是的。參見[php.net/file_put_contents](http://php.net/file_put_contents)。 – Randle392 2013-04-23 08:18:21
在路徑前加上'pic.jpg'。就像'/ path/to/the/pic.jpg'或在Windows中,'C:/ path/to/the/pic.jpg'。 – Randle392 2013-04-23 08:23:35