Home > Backend Development > PHP Tutorial > php服务器 提示下载功能解决思路

php服务器 提示下载功能解决思路

WBOY
Release: 2016-06-13 13:29:30
Original
950 people have browsed it

php服务器 提示下载功能
我这里是PC端做服务器,现在别的电脑访问我这里,需要提示下载功能,怎么实现呢?

好像是在index.php里写下载吧?完全没这方面的经验,不知道该怎么做。

我加了这一段

PHP code
<!--

Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/

-->
<?php header("Content-type:application/rar");

header("Content-Disposition:attachment;filename=.rar");

readfile("E:\ziptest\2.1.1-b8.rar");

?>

Copy after login


然后该怎么做呢?

------解决方案--------------------
然后在别的电脑上访问这个页面呀
------解决方案--------------------
直接用html代码做个链接不行吗?
------解决方案--------------------
filename=aa.rar //这里要取个名字。不然会形成rar 文件。
------解决方案--------------------
PHP code

#down.php
$file = 'ASDFGgg.pdf';
_Download("files_dir/".$file, $file);

function _Download($f_location,$f_name){
     header ("Cache-Control: must-revalidate, post-check=0, pre-check=0");
   header('Content-Description: File Transfer');
   header('Content-Type: application/octet-stream');
   header('Content-Length: ' . filesize($f_location));
   header('Content-Disposition: attachment; filename=' . basename($f_name));
   readfile($f_location); 
 }
<br><font color="#e78608">------解决方案--------------------</font><br>
Copy after login
探讨

我在LocalSettings.php上加了这3行代码:
PHP code

header("Content-type:application/rar");

header("Content-Disposition:attachment;filename=SQLite.rar");

readfile("E:\ziptest\SQLite.rar");


登录首页的时候,有下载提示,但是……
Related labels:
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template