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 Link to comment https://forums.phpfreaks.com/topic/28941-php-download-script/ 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 Link to comment https://forums.phpfreaks.com/topic/28941-php-download-script/#findComment-132532 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! Link to comment https://forums.phpfreaks.com/topic/28941-php-download-script/#findComment-132545 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! Link to comment https://forums.phpfreaks.com/topic/28941-php-download-script/#findComment-132555 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.