サーバーからユーザーにファイルをダウンロードするためのphpページを書いています。これが私のコードです:
clearstatcache();
//Output stream to client
header("Pragma: public");
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Cache-Control: private", false);
header("Content-Type: application/zip");
header("Content-Disposition: attachment; filename=\"" . $zipName . "\"; filename*=utf-8''" . rawurlencode($zipName) . ";");
header("Content-Transfer-Encoding: binary");
header("Accept-Ranges: bytes");
header("Content-Length: " . (filesize($downloadFile)));
$fp = fopen($downloadFile, "rb");
ob_clean();
while (!feof($fp) && ( connection_status() == 0 ) && !connection_aborted()) {
print( fread($fp, 1024 * 1024));
flush();
ob_flush();
}
fclose($fp);
私は問題に直面しています: ユーザーがダウンロードボタンをクリックすると、サーバーはファイルをユーザーに送信します。ユーザーがファイルをダウンロードしているときに、ユーザーがダウンロード ボタンを再度クリックすると、要求が実行されません (他のすべての要求を実行できませんでした)。ユーザーが最初のファイルを完全にダウンロードすると、2 番目のファイルが開始されます。