<?php
header('Content-type:text/html;charset=utf-8');
$file_path = './images/beauty.jpg';
file_exists($file_path) or die('文件不存在');//判断文件是否存在
//文件信息
$file_size = filesize($file_path);
$file_name = basename($file_path);
//以只读方式打开文件
$fp = fopen($file_path,'r');
header("Content-type:application/octet-stream");
header("Accept-Ranges:bytes");
header("Accept-Length:".$file_size);
header("Content-Disposition:attachment;filename=".$file_name);
$content = fread($fp,$file_size);
//若文件过大,也可以每次只读取1024字节
/*
$content = '';
while(!feof($fp)){
$content .= fread($fp,1024);
}
*/
echo $content;
?>
header('Content-type:text/html;charset=utf-8');
$file_path = './images/beauty.jpg';
file_exists($file_path) or die('文件不存在');//判断文件是否存在
//文件信息
$file_size = filesize($file_path);
$file_name = basename($file_path);
//以只读方式打开文件
$fp = fopen($file_path,'r');
header("Content-type:application/octet-stream");
header("Accept-Ranges:bytes");
header("Accept-Length:".$file_size);
header("Content-Disposition:attachment;filename=".$file_name);
$content = fread($fp,$file_size);
//若文件过大,也可以每次只读取1024字节
/*
$content = '';
while(!feof($fp)){
$content .= fread($fp,1024);
}
*/
echo $content;
?>
1836

被折叠的 条评论
为什么被折叠?



