Цитата:
|
Пробовал ставить туда разные значения, изменений не было.
|
Цитата:
|
Цитата:
Положил на сервер HTML <!DOCTYPE html> <html> <head> <meta http-equiv="Content-type" content="text/html; charset=utf-8" lang="ru"> <meta name="viewport" content="width=device-width, initial-scale=1.0" > <title>TESTE </title> </head> <body> <button id='gpdf'>Load pdf</button> <script> document.getElementById('gpdf').addEventListener('click', ()=> { window.open('gpdf.php','fpdf') }) </script> </body> </html> Вот такой gpdf.php <?php header("Content-Type: application/pdf; name=\"file.pdf\""); header("Content-Disposition: inline; filename=\"file.pdf\""); readfile("file.pdf"); ?> и какой то file.pdf Все в хроме нормально работает. В новой вкладке открывается pdf. Сохраняется, как pdf хоть через 5 сек, хоть через 50 |
Цитата:
|
Цитата:
|
Всем спасибо за помощь. На другом сервере (nginx) всё отработало как надо.
Проблемы возникают на apache, в нём присутствует в Response Headers заголовок Keep-Alive: timeout=5, max=100. Вот эти 5 секунд. Если в скрипте написать вот так: header("Connection: close"); то файл не скачивается из просмотрщика прямо сразу, предлагает скачать скрипт. |
Цитата:
Поставил в скрипт указанный заголовок Все равно приходит и скачивается pdf. Хоть через 5 сек, хоть через 50. Вот, что имеем в сети General Request URL: http://localhost/teste/xtests/testpdf1/gpdf.php Request Method: GET Status Code: 200 OK Remote Address: 127.0.0.1:80 Referrer Policy: no-referrer-when-downgrade Response Headers Connection: close Content-Disposition: inline; filename="file.pdf" Content-Type: application/pdf; name="file.pdf" Date: Fri, 11 Sep 2020 08:58:01 GMT Server: Apache Transfer-Encoding: chunked Request Headers Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9 Accept-Encoding: gzip, deflate, br Accept-Language: ru-RU,ru;q=0.9,en-US;q=0.8,en;q=0.7 Cache-Control: no-cache Connection: keep-alive DNT: 1 Host: localhost Pragma: no-cache Referer: http://localhost/teste/xtests/testpdf1/indexa.html Sec-Fetch-Dest: document Sec-Fetch-Mode: navigate Sec-Fetch-Site: same-origin Sec-Fetch-User: ?1 Upgrade-Insecure-Requests: 1 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.102 Safari/537.36 |
Часовой пояс GMT +3, время: 06:54. |