PHP头条
热点:

图片存储与浏览一例(Linux+Apache+PHP+MySQL)


注意本程序使用的表结构为:
    use test;
    create table image(
                       id int unsigned auto_increment Prima(最完善的虚拟主机管理系统)ry key,
                       description text,
                       filename varchar(50),
                       filesize int,
                       filetype varchar(50),
                       filedata longblob
                      );
*/

//?cmd={read|list|form|store}

//检查cmd参数的合法性
switch($cmd){
   case read:
      break;
   case list:
      break;
   case form:
      break;
   Case store:
      break;
   default:
      $cmd = list;
      break;
}

switch($cmd){
   case read:
      //?cmd=read&id={}
      //读一个图片
      $server = MySQL(和PHP搭配之最佳组合)_connect("localhost","test","") or die("无法连接数据库服务器");
      MySQL(和PHP搭配之最佳组合)_select_db("test",$server) or die("无法连接数据库");
      $sql = "select filetype,filedata from image where id=$id";
      $rst = MySQL(和PHP搭配之最佳组合)_query($sql,$server) or die("$sql查询出错");
      if($row=MySQL(和PHP搭配之最佳组合)_fetch_row($rst)){
         header("Content-Type:" . $row[0]);
         echo $row[1];
      }
      else{
         echo "没有找到该记录";
      }
      MySQL(和PHP搭配之最佳组合)_free_result($rst);
      MySQL(和PHP搭配之最佳组合)_close($server) or die("无法与数据库服务器断开连接");
      break;
   case list:
      //?cmd=list
      //显示所有图片
      echo <html>;

www.phpzy.comtrue/phprm/34550.htmlTechArticle图片存储与浏览一例(Linux+Apache+PHP+MySQL) 注意本程序使用的表结构为: use test; create table image( id int unsigned auto_increment Prima (最完善的虚拟主机管理系统) ry key, description text, filename varchar(5...

相关文章

    暂无相关文章

PHP之友评论

今天推荐