Jump to content

download .pdf file


Shazbot!

Recommended Posts

I have successfully uploaded adobe .pdf's to a mssql 2005 server but now I am having issues downloading the file.

 

in IE

The download window will pop-up and ask to save or download.

if Download is chosen it will begin the transfer but stalls and says connect to server timeout.

 

if I open it I get binary description of the file.

 

in Firefox

The download window appears but the OK button is disabled.

 

I have been searching for different methods of downloading the file and here is the code that I have:

 

The file I am testing is only 213KB

 

 

$file = mssql_fetch_array($result);
//obtained from http://www.phpfreaks.com/forums/index.php/topic,141818.0.html
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/pdf");
header("Content-Disposition: attachment; filename=$file[3]");
header("Content-Transfer-Encoding: binary");
header("Content-Length: $file[2]");
readfile("$file[0]");



/*	
or
header("Content-type: application/pdf");
//header("Cache-Control: public, no-cache");
//header("Content-type: application/octetstream");
header("Content-length: $row[2]"); //size
header("Content-Disposition: attachment; filename=$file[3]"); 
header("Content-Description: File Transfer");
header("Content-Transfer-Encoding: binary");
//	header("Content-Description: PHP Generated Data");
//readfile($file[0]);
echo $file[0];



*/


 

thanks in advance

 

 

 

Link to comment
https://forums.phpfreaks.com/topic/57751-download-pdf-file/
Share on other sites

From the manual:

 

<?php
// We'll be outputting a PDF
header('Content-type: application/pdf');

// It will be called downloaded.pdf
header('Content-Disposition: attachment; filename="downloaded.pdf"');

// The PDF source is in original.pdf
readfile('original.pdf');
?>

Link to comment
https://forums.phpfreaks.com/topic/57751-download-pdf-file/#findComment-286018
Share on other sites

Thanks chigley ,

That worked to some degree, the file will download corrupted  because there is no content-length listed. If I add the content-length less than 999 it works, but the file is still corrupted. If the length is greater than 999 then it will stall and not download.

 

Not saying that the content-length is causing the corruption but there is something happing here that is causing the file to be downloaded corrupted.

 

 

Link to comment
https://forums.phpfreaks.com/topic/57751-download-pdf-file/#findComment-286118
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.