//儲存圖片到資料庫的php程式碼
複製程式碼 程式碼如下:
If($Picture != "none" ) {
$PSize = filesize($Picture);
$mysqlPicture = addslashes(fread(fopen($Picture, "r"), $PSize));
mysql_connect($host,$$username, $password) or die("Unable to connect to SQL server");
@mysql_select_db($db) or die("Unable to select database");
mysql_query("INSERT INTO Images (Image) VALUES (Image) VALUES ( $mysqlPicture)") or die("Cant Perform Query");
}else {
echo"You did not upload any picture";
}
複製代碼 代碼如下:
mysql_connect($host,$username, $password) or die("Unable to connect to SQL server");
@mysql_select_db($db) or die("Unable to select database");
$result=mysql_query("SELECT * FROM Images" ) 或 die("Cant Perform Query");
While($row=mysql_fetch_object($result)) {
echo "" ;
//如secoed.php檔案代碼如下
$result=mysql_query("SELECT * FROM Images WHERE PicNum=$PicNum") 或 die("Cant perform Query");
$row=mysql_fetch_object ($result);
Header( "Content-type: image/gif");
echo $row->Image;
以上就介紹了免費mysql資料庫 php下將圖片以二進位存入mysql資料庫中並顯示的實作程式碼,包括了免費mysql資料庫方面的內容,希望對PHP教學有興趣的朋友有所幫助。