如何在网页中实现文件下载? 是简单的<a href="filePath" target="_blank">文件下载</a>还是用PHP实现?麻烦说一下呵呵 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 有人跟你问了同样的问题参考http://topic.csdn.net/t/20000914/08/29859.html 第一:<a href="aaa.txt">下载</a>方式2:<?php$filename = "theDownloadedFileIsCalledThis.mp3";$myFile = "/absolute/path/to/my/file.mp3";$mm_type="application/octet-stream";header("Cache-Control: public, must-revalidate");header("Pragma: hack"); // WTF? oh well, it works...header("Content-Type: " . $mm_type);header("Content-Length: " .(string)(filesize($myFile)) );header('Content-Disposition: attachment; filename="'.$filename.'"');header("Content-Transfer-Encoding: binary\n");readfile($myFile);?> wamp环境搭建提问,急!!在线等!! 有插件的网站应该怎么架构? 网页过期 php数组如何让javascript调用? 求mysql的下载地址 php图片上传的问题,急~在线等 请问在PHP文件里能否嵌入C语言!? 高手帮帮忙:如何把中文字符转换成十六进制字符呢? session在IIS下问题 求PHP采取淘宝商品的解决方案。 【求助】能用php下载别的网站的流媒体文件吗【急】 php怎样提取相应的css项目生成到新的css文件中去(2)?
参考http://topic.csdn.net/t/20000914/08/29859.html
<a href="aaa.txt">下载</a>方式2:
<?php
$filename = "theDownloadedFileIsCalledThis.mp3";
$myFile = "/absolute/path/to/my/file.mp3";$mm_type="application/octet-stream";header("Cache-Control: public, must-revalidate");
header("Pragma: hack"); // WTF? oh well, it works...
header("Content-Type: " . $mm_type);
header("Content-Length: " .(string)(filesize($myFile)) );
header('Content-Disposition: attachment; filename="'.$filename.'"');
header("Content-Transfer-Encoding: binary\n");readfile($myFile);?>