欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

php下將圖片以二進(jìn)制存入mysql數(shù)據(jù)庫中并顯示的實現(xiàn)代碼

 更新時間:2010年05月27日 03:44:21   作者:  
php把圖片存入mysql教程數(shù)據(jù)庫教程中并在網(wǎng)頁上顯示,一般情況下并不需要將突破保存到數(shù)據(jù)庫中,不論是異地備份還是什么的,都很麻煩,特殊需要的除外。
//保存圖片到數(shù)據(jù)庫的php代碼
復(fù)制代碼 代碼如下:

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 ($mysqlPicture)") or die("Cant Perform Query");
}else {
echo"You did not upload any picture";
}

//以img標(biāo)簽讀取數(shù)據(jù)庫中的圖片的代碼
復(fù)制代碼 代碼如下:

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") or die("Cant Perform Query");
While($row=mysql_fetch_object($result)) {
echo "<IMG SRC="Second.php3? PicNum=$row->PicNum">";

//如secoed.php文件代碼如下
$result=mysql_query("SELECT * FROM Images WHERE PicNum=$PicNum") or die("Cant perform Query");
$row=mysql_fetch_object($result);
Header( "Content-type: image/gif");
echo $row->Image;

相關(guān)文章

最新評論