我的根目录中有一个名为files
的文件夹。 此文件夹包含范围从1 Kb-1 GB
的文件。将文件从服务器下载到客户端的计算机
我想要一个php脚本,可以简单地使用AJAX异步下载文件。
此代码启动下载脚本点击一个文件时:
JQUERY
$('.download').click(function(){
var src =$(this).attr('src');
$.post('download.php',{
src : src //contains name of file
},function(data){
alert('Downloaded!');
});
});
PHP
<?php
$path = 'files/'.$_POST['src'];
//here the download script must go!
?>
这将是最好,最快,安全下载文件的方式?
- 为什么?你需要做什么不能通过让服务器管理它来完成?为什么你需要涉及Ajax? – Quentin 2014-10-06 06:12:28