Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/361.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何使用PHP或JavaScript检查下载是否完成?_Javascript_Php - Fatal编程技术网

如何使用PHP或JavaScript检查下载是否完成?

如何使用PHP或JavaScript检查下载是否完成?,javascript,php,Javascript,Php,我可以使用PHP创建带有过期时间的动态下载链接。但是我想在用户完成下载后删除链接。有没有办法知道用户何时使用PHP或JavaScript完成下载?使用PHP页面处理用户的下载请求,这将触发用户在短时间后删除该请求?这通常由客户端处理 你可以找到一个相关问题的很好的答案 我处理这个问题的方法是使用jQuery。在JavaScript中,我异步启动下载,调用函数允许调用回调函数。在这个回调函数中,您可以清空与下载链接对应的div,并可能向服务器发送消息 // have a div in yo

我可以使用PHP创建带有过期时间的动态下载链接。但是我想在用户完成下载后删除链接。有没有办法知道用户何时使用PHP或JavaScript完成下载?

使用PHP页面处理用户的下载请求,这将触发用户在短时间后删除该请求?

这通常由客户端处理

你可以找到一个相关问题的很好的答案

我处理这个问题的方法是使用jQuery。在JavaScript中,我异步启动下载,调用函数允许调用回调函数。在这个回调函数中,您可以清空与下载链接对应的div,并可能向服务器发送消息

    // have a div in your document to call this JavaScript script
    // first get the file in local memory
    var file = "myfile.csv";
    $.get(file, function(data){
        // everything here will be done only when the download is finished
        // in particular you want the user to be able to get the file using 
         mydoc.execCommand("saveAs",true,".txt");

        // as described 
        // here: http://www.webdeveloper.com/forum/showthread.php?12509-how-to-pop-up-Save-As-Window

        // you can also change the div containing the link/button activating the download 
        // and possibly send the server a download OK signal

}))

不可靠地使用JavaScript AFAIK。你能做的最好的事情是在你选择的N天,小时后自动删除文件。这就是为什么所有网站(确实有类似的网站)都会说“亲爱的用户,您的下载链接将在N时间内可用。”您想删除指向该文件的链接还是链接的文件?相关和
短时间
在互联网连接快速的城镇和移动连接的荒凉村庄中是不一样的。根据文件大小,您可以将拨号连接考虑在内,然后长时间删除该文件,或者在请求后24小时。您如何可靠地说“是的,客户端已成功下载该文件?”?这就是异步下载功能的工作。只有在下载完成后,它才会调用回调函数。请您指出一些说明如何使用成功的下载回调函数的文档?