forcing file downloads
| From: | Justin French | Date: | Wed, 12 Jun 2002 13:01:03 +0000 |
| Subject: | forcing file downloads | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-101721@lists.php.net to get a copy of this message | ||
I know this has been discussed many times, but I've been hunting through the
archives with very little resolution on the issue.
I've found the following note in the annotated manual:
> Additional notes to my workaround on Q266305:
>
> I have tested my findings with PDF, XLS, DOC and ZIP. However JPG and GIF
> didn't make IE pop up the download box. By changing content type from
> "octet-stream" to "force-download" (or some undefined
> type), it will work. Of course, we need to take care of other browsers
> too. Here is the improved code, hope it helps:
>
> header("Content-type: application/force-download");
>
> if (strstr($_SERVER["HTTP_USER_AGENT"], "MSIE"))
> header("Content-Disposition: filename=$myfile" .
> "%20"); // For IE
> else
> header("Content-Disposition: attachment; filename=$myfile");
> // For Other browsers
>
> Note: If you are using session together with this download, you will need
> to add the following line BEFORE the code above to make IE work:
>
> session_cache_limiter("");
1. Is this a widely accepted practice for forcing downloads (a pop-up window
to download a file), given the problems with older versions of IE?
2. Can someone tell me what the %20 is there for?
Regards,
Justin French