downloading PDFs
Posted: Fri Oct 13, 2006 4:25 am
Hi
I have set up a site where the user can download a pdf .
The code I am using is as folllows:
This works fine when I want to save the pdf to my system, howeve when I choose to open it there is an error saying the file could not be found. - This error is only expeirenced in IE
Does anyone know where I have gone wrong here?
Thanks in advance
I have set up a site where the user can download a pdf .
The code I am using is as folllows:
Code: Select all
$TJ_PDF_PATH = '/usr/local/home/httpd/vhtdocs/host/web/assets/news/ ';
$path =''.$TJ_PDF_PATH.''.$news_pdf.'';
if (file_exists($path))
{
$size = filesize($path);
$file = basename($path);
header("Content-Type: application/octet-stream");
header("Content-Type: application/download");
header("Content-Disposition: attachment; filename=$file");
header("Content-Length: $size");
readfile($path);
header("Location: $path");
}
else {
print 'There was a problem with the download, please contact for assistance';
}Does anyone know where I have gone wrong here?
Thanks in advance