Look's correct... you could consider adding
Header("Content-transfer-encoding: binary");
But I highly doubt that would fix things. It would help much more if you
pasted the output by the server...
The link you pasted us is not sending any of the headers you set. Maybe you
already expired this url... but that surely won't help us in debugging!
These are the headers returned by your script...
200 OK
Cache-Control: private, no-cache
Connection: close
Date: Tue, 11 Nov 2003 17:05:43 GMT
Pragma: no-cache
Server: Apache/1.3.28 (Unix) mod_auth_passthrough/1.8 mod_jk/1.2.0
mod_log_bytes/1.2 mod_bwlimited/1.2 PHP/4.3.3 FrontPage/5.0.2.2634
mod_ssl/2.8.15 OpenSSL/0.9.6bContent-Type: text/html
Expires: Mon, 26 Jul 1997 05:00:00 GMT
Client-Date: Tue, 11 Nov 2003 17:05:49 GMT
Client-Peer: 69.57.134.79:80
Set-Cookie: PHPSESSID=ffa3f76470f259ca96fb630dbbc1307d; path=/
X-Powered-By: PHP/4.3.3
The content returned by your script is HTML not PDF!
It start's off with...
<HTML>
<HEAD>
<TITLE>SunGard Trading and Risk Systems - Download page</TITLE>
Here is the example output of a working binary download that we use. See the
difference.
> HEAD http://localhost/dl.php
HTTP/1.1 200 OK
Date: Tue, 11 Nov 2003 16:58:03 GMT
Server: Apache/1.3.27 (Unix) PHP/4.1.2
Content-disposition: attachment; filename=app.exe
Content-transfer-encoding: binary
Content-length: 208670
Connection: close
Content-Type: application/octet-stream
There is clearly something else broken with your script and it's not in the
part of code you sent us. Not only are the headers not what you set, the
file isn't what your passing. Hope this helps.
Also, stylistically I would use a switch(..) statement. It lends itself
perfectly for the kind of thing you're trying to do...
switch($type)
{
case 'pdf': $mimeinfo = "application/pdf"; break;
case 'doc': $mimeinfo = "application/msword"; break;
default: $mimeinfo = "application/octet-stream";
}
Regards,
Erik Osterman
http://osterman.com/
-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED]
Sent: Tuesday, November 11, 2003 7:57 AM
To: [EMAIL PROTECTED]
Subject: [PHP] Passing header info for use in downloading files...?
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";}
header("Content-Disposition: attachment; filename=$file");
header("Content-Length: " . filesize($path));
header("Content-Type: $mimeinfo");
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.
***********************************************************************
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php