//保存图片到数据库的php代码 <div class="codetitle"><a style="CURSOR: pointer" data="42866" class="copybut" id="copybut42866" onclick="doCopy('code42866')"> 代码如下:<div class="codebody" id="code42866"> 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标签读取数据库中的图片的代码 <div class="codetitle"><a style="CURSOR: pointer" data="34580" class="copybut" id="copybut34580" onclick="doCopy('code34580')"> 代码如下:<div class="codebody" id="code34580"> mysql_connect($host,$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;
(编辑:李大同)
【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!
|