【问题标题】:PHP check if file was download completelyPHP检查文件是否完全下载
【发布时间】:2015-05-21 22:42:39
【问题描述】:

有没有办法检测用户何时下载整个文件?我正在使用此脚本下载 ZIP 文件:

header($_SERVER['SERVER_PROTOCOL'] . ' 200 OK');
header("Content-Type: application/zip");
header("Content-Transfer-Encoding: Binary");
header("Content-Length: " . filesize($filePath));
header("Content-Disposition: attachment; filename=\"" .$fileName . "\"");

我阅读了一些建议,但没有人有效。如果您有有效且经过测试的解决方案,我会很高兴。

谢谢

【问题讨论】:

标签: php download zip


【解决方案1】:

您也可以每隔 n 秒检查一次文件是否存在:

file_put_contents("folder/file", fopen(file_url, 'r'));
while(!file_exists('folder/file')){
   sleep (5);
}

//Do your stuff with the downloaded file 

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2013-05-18
    • 1970-01-01
    • 2021-05-23
    • 2021-04-26
    • 2020-06-26
    • 2018-02-03
    • 2010-12-06
    • 1970-01-01
    相关资源
    最近更新 更多