PHP put pictures into MySQL data library----in the process of building the site, I share with you the image in PHP Mysqldata Library and display the Code on the page, as follows:
Save the image to the data library
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 do not upload no picture";
}
To read a picture from the data library with an IMG tag
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 "";
such as the secoed.php file code is as follows
$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;
......
Note: This article by the Mianyang website construction expert "Strange far science and technology www.7wangzhanjianshe.com" collation, quoted please indicate the source!
PHP storing images in MySQL data library