Home > Backend Development > PHP Tutorial > php下载问题报错不知道什么原因?

php下载问题报错不知道什么原因?

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-02 11:34:22
Original
961 people have browsed it

php

$file_name = "顺平.jpg";
$file_name=iconv("GB2312","GBK",$file_name);//报错。。。。能帮忙改一下吗?
if(!file_exists($file_name))
{
echo"文件不存在";
return ;
}
$fp = fopen($file_name,"r");
$file_size = filesize($file_name);
$fp = fopen($file_name,"r");
//获取下载文件的大小
$file_size = filesize($file_name);
//返回的文件
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);

<code>    //统计读了多少个字节    $file_count+=$buffer;    //把部分数据回送给浏览器    echo $file_data;}    fclose($fp);</code>
Copy after login

?>

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