Hello,
I have a particular situation where files (.doc, xls, .pdf, etc...) are stored outside of the root web and accessed via a php file. It seems I cannot emulate the typical behavior of "auto opening" the file in the appropriate application with this approach. The browser always prompts to save. Is it possible to open the file with php headers or something similarly to directly linking to it?
My primary concern with this situation is that the sites search tool can no longer index these documents.
Thanks in advance.
auto open behavior for files accessed via php
Moderator: General Moderators
Re: auto open behavior for files accessed via php
The way a browser handles different types of files is dependent on how a user has configured the browser. You cannot, as a developer, force the user to open a particular file type with a particular application (which may or may not exist on the client's system). Likewise, you cannot specify the folder to which the user will download the file.
You may have to specify the appropriate Content-Type header when serving the file from PHP so the browser will recognize it.
You may have to specify the appropriate Content-Type header when serving the file from PHP so the browser will recognize it.