知道文件的路径如何实现浏览器端的下载(文件是源文件) 本帖最后由 u013293559 于 2014-02-10 12:11:05 编辑 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 如果没有防盗链就header Location可以了 这个也要举例啊?<?php/* This will give an error. Note the output * above, which is before the header() call */header('Location: http://www.example.com/');exit;?>就手册上的例子,可以写成header('Location: $url'); //$url 自己处理如何获得 如果类似php这类。。应该不能下载吧。。下载以后也是html的 亲,php文件是不能下载的,只能下载一些前端的文件 比如:html,js,css 我好想没说明白 我的意思是 服务器上有个文件或者压缩包 可以得到路径 想把这个文件下载下来 用 php代码怎么写 ……看样子是作为客户端用比较简单就是file_get_contents($url)然后fwrite到本地一个文件复杂点就curl header('Content-Disposition:attachment;filename=test.php');readfile('a.php');//目标文件 <?php$file_dir = '';//定义文件路径$file_name = '';//定义文件名字$file = fopen($file_dir . $file_name,"r"); // 打开文件Header("Content-type: application/octet-stream");Header("Accept-Ranges: bytes");Header("Accept-Length: ".filesize($file_dir . $file_name));Header("Content-Disposition: attachment; filename=" . $file_name);// 输出文件内容echo fread($file,filesize($file_dir . $file_name));fclose($file);exit();?> PHP中网页跳转?ID=1001问题 php form不能自动提交 IIS+PHP连接sqlserver问题!!!急急急 PHP 执行MYSQL 不正确! 大家讨论一个SQL语句! 100分的问题!!答完就揭贴! 网页中引用另一个页面的问题,急 求教Apache+PHP的权限问题 如何设定表格的宽度 echo 中如何让大括号原样输出 php正则匹配的问题! 我喜欢的乱码问题,这次想不通了,看谁有解?
<?php
/* This will give an error. Note the output
* above, which is before the header() call */
header('Location: http://www.example.com/');
exit;
?>
就手册上的例子,可以写成
header('Location: $url'); //$url 自己处理如何获得
下载以后也是html的
看样子是作为客户端用
比较简单就是file_get_contents($url)然后fwrite到本地一个文件
复杂点就curl
readfile('a.php');//目标文件
<?php
$file_dir = '';//定义文件路径
$file_name = '';//定义文件名字
$file = fopen($file_dir . $file_name,"r"); // 打开文件
Header("Content-type: application/octet-stream");
Header("Accept-Ranges: bytes");
Header("Accept-Length: ".filesize($file_dir . $file_name));
Header("Content-Disposition: attachment; filename=" . $file_name);
// 输出文件内容
echo fread($file,filesize($file_dir . $file_name));
fclose($file);
exit();
?>