I use this code for download pdf file. Downloading started but when downloading is finish adobe could not open pdf file.
$file_url = "http://kolikokostagrejanje.rs/step7/proracun-short.pdf";
header('Content-Type: application/pdf');
header("Content-Transfer-Encoding: Binary");
header("Content-disposition: attachment; filename=proracun-short-skinuto.pdf");
readfile($file_url);
Current PHP version: 5.4.36
SOLVED
The problem was that pdf file has not had a permission 777.
Is file having read permission. Also check if same problem is occurring for other file (in case file is corrupted)
my guess is that your script may contain NOTICE or WARNING, so try disabling error reporting in the script to solve the problem.
error_reporting(0);
and it's always better to use readfile with error suppression operator especially when performing a download task
@readfile($path)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.