mysql|程序|数据
PHP代码:--------------------------------------------------------------------------------
// 文件名:filedb.php 将文件储存到数据库中
/*
将文件上传存入 MySQL 数据库的例子
数据表的结构如下:
CREATE TABLE files (
id int(4) NOT NULL auto_increment,
filename varchar(64),
filesize int(16),
filetype varchar(64),
filecontent longblob,
remark text,
PRIMARY KEY (id)
);
*/
// 设定系统参数变量,根据需要修改
$DB_SERVER = "127.0.0.1"; # 数据库连接字
$DB_USER = "root"; # 用户名
$DB_PASS = ""; # 密码
$DB_NAME = "article"; # 数据库名
$TABLE_NAME = "files"; # 数据表名
$HANDLER_SCRIPT = "mysql数据库显示文件.php"; # 处理数据的脚本文件名
$PHP_SELF=$_SERVER['PHP_SELF'];
?>
| ID | 文件名 | 文件大小 | 文件类型 | 说明 | 连接 | 删除 |
|---|---|---|---|---|---|---|
| $row[id] | $row[filename] | $row[filesize] | $row[filetype] | $remark | 点击查看 |
$result = mysql_query($query_string) or die("查询出错!"); if (mysql_num_rows($result) == 0) // 判断查询是否成功 die("查无记录!"); $row = mysql_fetch_array($result); # 取得查询结果 $filecontent = $row["filecontent"]; # 取得文件内容 $filetype = $row["filetype"]; # 取得文件类型 $filename = $row["filename"]; # 取得文件名 header("Content-Type: $filetype"); # 输出 HTTP 头信息,文件的 MIME 类型 header("Content-Disposition: inline; filename=\"$filename\""); # 这样可以给出文件# header("Content-Disposition: attachment; filename=\"$filename\""); # 这样可以迫使 IE 下载文件而不显示 echo $filecontent; # 输出文件 } } ?>
|
每个人都需要一台速度更快、更稳定的 PC。随着时间的推移,垃圾文件、旧注册表数据和不必要的后台进程会占用资源并降低性能。幸运的是,许多工具可以让 Windows 保持平稳运行。
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号