You are here: Re: [PHP] Re: Hidden File Downloads « PHP « IT news, forums, messages
Re: [PHP] Re: Hidden File Downloads

Posted by Philip Hallstrom on 10/15/34 11:14

>> This is what I do to "force" excel docs to be downloaded...
>>
>> Header("Content-Type: application/vnd.ms-excel");
>
>This tells the browser that it's an Excel file.
>
>> Header("Content-Disposition: attachment; filename=general-data.xls");
>
>This tells Microsoft browsers (who I think made up all the stuff in this
>line on their own, disregarding existing standards) to handle this file as
>an "attachment" and to name it "general-data.xls"
>
>Now, I really don't know why their BROWSERS want to use the word
>"attachment" (usually used in email) nor what that's supposed to mean,
>but...
>
>This will most likely *FAIL* for older non Microsoft browsers,
>particularly if the user has some kind of plug-in that allegedly can
>"handle" MS Excel files.
>
>If you want to *FORCE* a download, the mime type
>"application/octet-stream" *WILL* do that in an HTTP-compliant browser
>(all of them).
>
>> I found that just using the content type itself wasn't enough...
>
>*WHICH* content type?

Honestly, I don't remember. I did it a couple of years ago and my memory
is that the above was the only thing that guaranteed a pop up save dialog.
Anything else and it would sometimes download, sometimes display inline,
and sometimes open excel depending on the browser.

I wasn't concerned with anything old at the time, so can't comment on
that.

Also, it might have something to do with the fact that the file I was
downloading was just tab deliminited text not a true excel file with
whatever file magic goes along with it...

>You're better off, though, to force the URL to end in the filename you
>want the user to use, as some browsers will not pay attention to the
>"attachment" header.

I definitely agree with you here...

-philip

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация