I have a page where the user clicks a link to download a file, but the file is out side of the root DIR.
passing certain variables in the link, (type, file_name) I call the correct file...
However, it's stopped working?
My code below shows how I select the correct mime info to pass to the header.. but I keep getting promted to download an HTML file all the time...
if ($type == 'pdf') {$mimeinfo = "application/pdf";} else
if ($type == 'doc') {$mimeinfo = "application/msword";} else
if ($type == 'exe') {$mimeinfo = "application/octet-stream";} else
if ($type == 'ppt') {$mimeinfo = "application/vnd.ms-powerpoint";} else
if ($type == 'xls') {$mimeinfo = "application/vnd.ms-excel";} else
if ($type == 'xml') {$mimeinfo = "text/xml";} else
if ($type == 'zip') {$mimeinfo = "application/zip";}
Don't know if this is the problem, but I would code this differently...
if ($type == 'pdf') { $mimeinfo = "application/pdf"; } elseif ($type == 'doc') { $mimeinfo = "application/msword"; } elseif ($type == 'exe') { $mimeinfo = "application/octet-stream"; } elseif ($type == 'ppt') { $mimeinfo = "application/vnd.ms-powerpoint"; } elseif ($type == 'xls') { $mimeinfo = "application/vnd.ms-excel"; } elseif ($type == 'xml') { $mimeinfo = "text/xml"; } elseif ($type == 'zip') { $mimeinfo = "application/zip"; }
But that's only if I had to use if/else....personally, I'd put all that in a switch statement.
header("Content-Disposition: attachment; filename=$file"); header("Content-Length: " . filesize($path)); header("Content-Type: $mimeinfo");
And here, again, don't know if it's the problem, but...I'd move the variable outside of the quotes....
header("Content-Type: " . $mimeinfo);
Just personal preference I guess....YRMV.
readfile("$path");
My problem page is:
http://www.risk.sungard.com/download/?id=12617
click in the link 'Settlements >>' and you'll see what I mean, it says it's a pdf, but when you have to specify the download location, it saves simply the html page?
can anyone spot my probably stupid error?
Tris...
*********************************************************************
The information contained in this e-mail message is intended only for the personal and confidential use of the recipient(s) named above. If the reader of this message is not the intended recipient or an agent
responsible for delivering it to the intended recipient, you are hereby notified that you have received this document in error and that any
review, dissemination, distribution, or copying of this message is strictly prohibited. If you have received this communication in error, please notify us immediately by e-mail, and delete the original message.
***********************************************************************
-- By-Tor.com It's all about the Rush http://www.by-tor.com
-- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php