Shazbot! Posted June 29, 2007 Share Posted June 29, 2007 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 Quote Link to comment Share on other sites More sharing options...
chigley Posted June 29, 2007 Share Posted June 29, 2007 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'); ?> Quote Link to comment Share on other sites More sharing options...
Shazbot! Posted June 29, 2007 Author Share Posted June 29, 2007 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. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.