[nycphp-talk] Anyway to force a download of GIF file?
Jerry Kapron
nyphp at NewAgeWeb.com
Thu Jul 17 15:41:02 EDT 2003
Mike,
Change
header("Content-type: 'application/octet-stream");
to
header('Content-type: application/force-download');
It should fix the Mac problem. However IE on Mac seems to totally ignore the Content-disposition header and will prompt to save as a .php file.
Jerry
-----Original Message-----
From: DeWitt, Michael <mjdewitt at alexcommgrp.com>
To: 'NYPHP Talk' <talk at lists.nyphp.org>
Date: Thursday, July 17, 2003 2:23 PM
Subject: RE: [nycphp-talk] Anyway to force a download of GIF file?
>Chris/Jerry,
>
>Thank you both for your suggestions. Using headers is definitely the way to
>go. After some playing around and reading up on compatibility issues, here
>is what I am working with so far:
>
><?php
>
>header("Pragma: public");
>header('Cache-Control: public');
>header("Content-type: 'application/octet-stream");
>header("Content-Length: ".filesize($FILE_PATH.$file));
>header("Content-Disposition: attachment; filename=$file");
>//echo "\\n";
>readfile($FILE_PATH.$file);
>
>?>
>
>The Pragma and cache-control seem to be needed by IE6 in order to work. the
>content type "image/gif" gave me some issues where the file was downloaded
>but corrupted. This stuff is completely ignored (broken) by IE on a
>Macintosh, It will always just display the file.
>
>Thanks a lot for your help.
>
>Mike
>
>> -----Original Message-----
>> From: Fee, Patrick J [SMTP:patrick.fee at baesystems.com]
>> Sent: Thursday, July 17, 2003 12:11 PM
>> To: 'shiflett at php.net'; 'NYPHP Talk'
>> Subject: RE: [nycphp-talk] Anyway to force a download of GIF file?
>>
>> Chris,
>>
>> This is slightly off-topic, but do you have any idea how to do that in
>> Cold
>> Fusion?
>>
>> Patrick J. Fee
>> Web & Database Group Manager
>> BAE SYSTEMS
>> 600 Maryland Ave. SW Suite 600
>> Washington D.C. 20024
>> Patrick.Fee at BAESYSTEMS.com
>> Tel: (202) 548-3759
>> Fax: (202) 608-5970
>>
>>
>>
>> -----Original Message-----
>> From: Chris Shiflett [mailto:shiflett at php.net]
>> Sent: Thursday, July 17, 2003 10:55 AM
>> To: NYPHP Talk
>> Subject: Re: [nycphp-talk] Anyway to force a download of GIF file?
>>
>>
>> --- "DeWitt, Michael" <mjdewitt at alexcommgrp.com> wrote:
>> > I have been looking around for a way to get browsers to download
>> > rather than display a GIF file.
>>
>> Have you looked into the Content-Disposition header? With it you can
>> specify
>> a
>> filename (convenient when the name of your PHP script isn't the name you
>> want
>> the browser to use), and you can indicate inline or attachment. You would
>> want
>> attachment.
>>
>> Double-check my syntax, but I think it would go something like this:
>>
>> header('Content-Disposition: attachment; filename=blah.gif');
>>
>> Hope that helps.
>>
>> Chris
>>
>> =====
>> Become a better Web developer with the HTTP Developer's Handbook
>> http://httphandbook.org/
>> _______________________________________________
>> talk mailing list
>> talk at lists.nyphp.org
>> http://lists.nyphp.org/mailman/listinfo/talk
>> _______________________________________________
>> talk mailing list
>> talk at lists.nyphp.org
>> http://lists.nyphp.org/mailman/listinfo/talk
>_______________________________________________
>talk mailing list
>talk at lists.nyphp.org
>http://lists.nyphp.org/mailman/listinfo/talk
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.nyphp.org/pipermail/talk/attachments/20030717/a3288b32/attachment.html>
More information about the talk
mailing list