检查文件是否已下载

编程入门 行业动态 更新时间:2024-10-28 18:25:28
本文介绍了检查文件是否已下载的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我使用以下代码提供下载: header(" Content-Type:$ mimetype" );; 标题(" Content-Disposition:attachment; filename = $ filename"); 标题(" Cache-Control:must-revalidate,post-check = 0,pre-check = 0"); header(" Content-Length:" .filesize($ temp_filename)); readfile_chunked($ temp_filename) ; (readfile_chunked来自 nl2.php/manual/nl/function.readfile.php ) 我的问题:如何检查如果文件已下载并保存?我想 下载后可以自动删除。 当用户点击取消并且没有下载时,该功能似乎退出 文件,因此以下所有命令都不会被执行。这是完美的。 然而,它不会在文件小到足以装入块时。 php'的 readfile似乎有相同的行为。所以,在这种情况下,即使点击了取消,所有以下 命令都会被执行(在我的应用程序中, 文件然后被删除,这不应该''当然发生了。) 另外检查发送的字节也无济于事。如果该函数存在,它总是 返回适合单个 块的小文件的完整文件大小,即使单击取消也是如此。 那么,有没有办法确定文件是否已下载并打开/保存而不是在下载对话框中点击取消? 在此先感谢,最好的问候, -Hendri Adriaens。

Hi, I use the following code to offer a download: header("Content-Type:$mimetype"); header("Content-Disposition: attachment; filename=$filename"); header("Cache-Control:must-revalidate,post-check=0,pre-check=0"); header("Content-Length:".filesize($temp_filename)); readfile_chunked($temp_filename); (readfile_chunked comes from nl2.php/manual/nl/function.readfile.php) My question: how can I check if the file was downloaded and saved? I want to make an automatic removal possible after download. The function seems to exit when the user clicks cancel and doesn''t download the file, so all following commands will not get executed. That''s perfect. However, it doesn''t when the file is small enough to fit in a chunk. php''s readfile seems to have the same behaviour. So, in that case, all following commands do get executed, even if cancel was clicked (and in my application, the file then gets removed, which shouldn''t happen of course). Also checking the bytes sent doesn''t help. If the function exists, it always returns the complete filesize for the small files that fit in a single chunk, even if cancel was clicked. So, is there any working way to determine if a file was downloaded and opened/saved instead of cancel being clicked in the download dialog? Thanks in advance, best regards, -Hendri Adriaens.

推荐答案

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

filename"); header(" Cache-Control:must -revalidate,post-check = 0,pre-check = 0"); header(" Content-Length:" .filesize( filename"); header("Cache-Control:must-revalidate,post-check=0,pre-check=0"); header("Content-Length:".filesize(

temp_filename )); readfile_chunked( temp_filename)); readfile_chunked(

更多推荐

检查文件是否已下载

本文发布于:2023-11-26 16:14:55,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1634356.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:文件

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!