如何使用PHP下载图片,而不是在浏览器中打开图片 header('Content-Type:application/x-download'); 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 主要发送下面两部分就成了.....header('Content-Type: 图片的MIME');header("Content-disposition: attachment; filename=\"图片文件名\""); .... 改成如下形式$file_path = WWW_ROOT . $path . DS . $file_name; $fileLineArray = file($file_path); header('Content-Type: application/octet-stream'); header("Content-Disposition:attachment;filename=$file_name"); foreach($fileLineArray as $fileLine) { echo $fileLine; } image.php<?php//数据库部分自己改$link=mysql_connect("localhost","root","123456"); mysql_select_db('test',$link); mysql_query("set names gb2312"); $recid = $_GET['recid'];$query="select * from tb_tpsc where id = $recid";$result=mysql_query($query);$info = mysql_fetch_array($result);header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");header("Cache-Control: post-check=0, pre-check=0", false);header("Pragma: no-cache");header('Content-Type: image/jpeg'); //想办法获取文件扩展名,我这里默认的给的是jpeg的,这个你没有存起来header("Content-Disposition:filename=". $info['tpmc'] . ".jpeg");echo $info['file'];?> 下载的话,只需要加个链接到这个地址就OK.比如说 image.php?recid=xxx PHP中关于数据库使用问题 数据库中提取数据 字符串处理成数字问题?? php简单问题 php 怎样记录一个页面里的连接 被点击了多少次 关于header的问题 有个1千万用户表,name不会重复的,要不要用limit 1啊? PHP上传文件的问题 一个C语言的函数,如何转换成用PHP写的函数 请 alexzhang00(三角猫(sjcatsoft)) 进来拿分,谢谢解答php操控MYSQL的问题 php 得到 js 动态生成的input值 PHP简单图片上传,看看哪出问题了?
header('Content-Type: 图片的MIME');
header("Content-disposition: attachment; filename=\"图片文件名\"");
....
$file_path = WWW_ROOT . $path . DS . $file_name;
$fileLineArray = file($file_path);
header('Content-Type: application/octet-stream');
header("Content-Disposition:attachment;filename=$file_name");
foreach($fileLineArray as $fileLine) {
echo $fileLine;
}
<?php
//数据库部分自己改
$link=mysql_connect("localhost","root","123456");
mysql_select_db('test',$link);
mysql_query("set names gb2312"); $recid = $_GET['recid'];
$query="select * from tb_tpsc where id = $recid";
$result=mysql_query($query);
$info = mysql_fetch_array($result);header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
header('Content-Type: image/jpeg');
//想办法获取文件扩展名,我这里默认的给的是jpeg的,这个你没有存起来
header("Content-Disposition:filename=". $info['tpmc'] . ".jpeg");
echo $info['file'];
?>
比如说 image.php?recid=xxx