bxt0058 2014-06-04 16:11 采纳率: 0%
浏览 891

php 下载中文图片报错问题

放在不同页面中运行他会报出下载的图片不存在的错误但是我的图片存在
英文的图片名可以但是中文的图片名就报文件不存在为什么?帮忙改正一下。。。。
ShowPicture.php页面如下:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">



无标题文档


点击下载
点击下载

<?php
$str = urlencode("顺平.jpg");
echo "点击下载"
?>
点击下载


DownPicture.php页面如下:
<?php
header("Expires: -1");
header("Cache-Control: no_cache");
header("Pragma: no-cache");
header("Content-Type: text/html; charset=utf-8");
require 'class/fileDown.class.php';
$name=urldecode($_REQUEST["name"]);
//echo $name;
down_file($name,"/MianXiangDuixiang/down/");
?>
fileDown.class.php页面如下:
<?php
header("Expires: -1");
header("Cache-Control: no_cache");
header("Pragma: no-cache");
header("Content-Type: text/html; charset=utf-8");
function down_file($file_name,$file_sub_dir)
{
$file_name=iconv("gb2312","GBK",$file_name);
$file_path = $_SERVER['DOCUMENT_ROOT'].$file_sub_dir.$file_name;
if(!file_exists($file_path))
{
echo"文件不存在";
return ;
}
$fp = fopen($file_path,"r");
$file_size = filesize($file_path);
header("Content-type: application/octet-stream");
header("Accept-Ranges: bytes");
header("Accept-Length: $file_size");
header("Content-Disposition: attachment; filename=".$file_name);
$buffer = 1024;
$file_count = 0;
while(!feof($fp) && ($file_size-$file_count>0))
{
$file_data = fread($fp,$buffer);
$file_count+=$buffer;
echo $file_data;
}
fclose($fp);
}
?>
  • 写回答

0条回答

    报告相同问题?

    悬赏问题

    • ¥30 这是哪个作者做的宝宝起名网站
    • ¥60 版本过低apk如何修改可以兼容新的安卓系统
    • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
    • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
    • ¥50 有数据,怎么用matlab求全要素生产率
    • ¥15 TI的insta-spin例程
    • ¥15 完成下列问题完成下列问题
    • ¥15 C#算法问题, 不知道怎么处理这个数据的转换
    • ¥15 YoloV5 第三方库的版本对照问题
    • ¥15 请完成下列相关问题!