Answer the question
In order to leave comments, you need to log in
Why is the entire site blocked when uploading a file?
Good afternoon, help please.
I'm trying to implement the issuance of a file for download.
I already managed to implement it, but after that a problem arose.
After the download starts, the page freezes completely and the user cannot go to another page or update the current one until the download is complete.
I take files from an external domain below the issuance code.
The fact is that on another domain this code works fine and does not block the page.
I've been googling all day yesterday and can't find anything.
Please tell me which way to dig.
Thanks in advance.
if ($fd = fopen($file, "r")) {
$path_parts = pathinfo($file);
// заставляем браузер показать окно сохранения файла
header('Content-Description: File Transfer');
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename=' . $path_parts['basename']);
header('Content-Transfer-Encoding: binary');
header('Expires: 0');
header('Cache-Control: must-revalidate');
header('Pragma: public');
header('Content-Length: ' . $filesize);
// читаем файл и отправляем его пользователю
while (!feof($fd)) {
print fread($fd, 1024);
}
fclose($fd);
}
die();
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question