点击下载
Home > Backend Development > PHP Tutorial > php 下载中文图片报错问题

php 下载中文图片报错问题

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-02 11:34:21
Original
1042 people have browsed it

php

放在不同页面中运行他会报出下载的图片不存在的错误但是我的图片存在
英文的图片名可以但是中文的图片名就报文件不存在为什么?帮忙改正一下。。。。
ShowPicture.php页面如下:




无标题文档


php 下载中文图片报错问题点击下载
php 下载中文图片报错问题点击下载
php 下载中文图片报错问题
$str = urlencode("顺平.jpg");
echo "点击下载"
?>
php 下载中文图片报错问题点击下载


DownPicture.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页面如下:
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);
}
?>
Related labels:
php
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Issues
php data acquisition?
From 1970-01-01 08:00:00
0
0
0
PHP extension intl
From 1970-01-01 08:00:00
0
0
0
How to learn php well
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template