Re: Help: a NS7 problem
| From: | Justin Patrin | Date: | Thu, 12 Aug 2004 01:49:37 +0000 |
| Subject: | Re: Help: a NS7 problem | ||
| References: | 1 | Groups: | php.windows |
| Request: | Send a blank email to php-windows+get-24388@lists.php.net to get a copy of this message | ||
On Wed, 11 Aug 2004 22:08:09 -0300, oleks <oleks@eastlink.ca> wrote:
> Hi All
>
> How to fix a NS7 problem where it wants to add a .PHP extension to all
> filenames
>
> I try to use this funnction:
>
> function download ($fileDir, $fileName) {
> $completeFilePath=$fileDir.'/'.$fileName;
> header('Pragma: no-cache');
> header("Content-type: archive/exe\n
> Content-Disposition: attachment;
> filename=\"" . $fileName . "\"\n
> Content-length: ".(string)(filesize($completeFilePath))
> );
> $fd=fopen($completeFilePath,'rb');
> while(!feof($fd)) {
> print(fread($fd, 4096));
> flush();
> }
> }
>
1) don't use newlines in your headers. Send each header with its own
header() call
2) browsers are fickle when it comes to downloading files. Search
Google and the lists for more ideas
Here's what I ended up with after lots of heartache:
header('Pragma: private');
header('Content-Type: '.$resource['mimeType']);
header('Content-Disposition: inline;
filename="'.$resource['fileName'].'"');
//header('Content-Length: '.strlen($resource['data']));
header('Content-Transfer-Encoding: binary');
echo $resource['data'];
I never got the content-length to work right, myself.
> MSIE6 works perfect but NS7 adds .php extension when I try to force NS7
> to download a file. How to fix this problem
>
> Thanks for help ...
> Oleks
>
> --
> PHP Windows Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
> !DSPAM:411ac0d2228921094323535!
>
>
--
DB_DataObject_FormBuilder - The database at your fingertips
http://pear.php.net/package/DB_DataObject_FormBuilder
paperCrane --Justin Patrin--