bsamson Posted November 30, 2006 Share Posted November 30, 2006 Hello, Could someone please direct me in the direction of a php download script. Here's my situation.I have many document types on my site including, PDF, DOC, XLS, and many more. With that said if a user clicks a link the document opens in IE. I am trying to figure out a way when a user clicks a link to one of these docs that it prompts them w/ a download dialog box. Again, any assistence would be GREATLY appreciated!Best Regards,Brian Samson Quote Link to comment Share on other sites More sharing options...
fert Posted November 30, 2006 Share Posted November 30, 2006 http://www.phpfreaks.com/forums/index.php/topic,95433.0.html Quote Link to comment Share on other sites More sharing options...
bsamson Posted November 30, 2006 Author Share Posted November 30, 2006 Thank you ... I was obviously searching for the wrong thing ... should've been 'force download'. Thanks! Quote Link to comment Share on other sites More sharing options...
bsamson Posted November 30, 2006 Author Share Posted November 30, 2006 Hello. After testing the script ... I think it is corrupting my pdf files ...Here's my code:[code]<?php// would reference script with: http://internal.mydomain.com/scripts/force.php?f=doc.pdf$pth = "http://internal.mydomain.com/docs/";$f = $_REQUEST['f'];$file = $pth . $f;header("Pragma: public");header("Expires: 0");header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); header('Accept-Ranges: bytes');header('Content-Length: ' . filesize($file));header("Content-Type: application/force-download");header("Content-Disposition: attachment; filename=".basename($file));header("Content-Description: File Transfer");@readfile($file);?>[/code] When I attempt to open once downloaded I get this error in adobe:[i] Adobe Reader could not open 'doc.pdf' because either it is not a supported file type or because the file has been damaged (for example, it was sent as an email attachement and wasn't correctly decoded.)[/i] But When i download directly it works fine ... any suggestions? Thanks! 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.