我使用以下代码提供下载: 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(
更多推荐
检查文件是否已下载
发布评论