标签:
function getTmp(){ $file_name = ‘orderTemp.xlsx‘; $file_path = dirname(__FILE__); #判断文件是否存在 if(! file_exists($file_path. ‘/‘ .$file_name)){ echo "file not exists"; return; } #存在的话,只读方式打开 $fp = fopen($file_name,"r"); #获取文件大小 $file_size = filesize($file_name); #让下载的文件名是中文 $file_name = iconv(‘UTF-8‘, ‘gbk‘, ‘订单表格模板.xlsx‘); #设置头 header("Content-Type: application/octet-stream"); header("Accept-Ranges: bytes"); header("Accept-Length: $file_size"); header("Content-Disposition: attachment; filename=" . $file_name); #设定一次读取的字节数 $buffer = 1024; #存储文件到本地 while(! feof($fp)){ $file_data = fread($fp,$buffer); echo $file_data; } fclose($fp); }
标签:
原文地址:http://www.cnblogs.com/wange/p/4940522.html