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
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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.