浏览器中的PHP / JS文档查看器

I have many different document filetypes that should be downloadable by users. These include presentations, PDF, excel etc etc. May also be mac filetypes too.

I'd like it to be possible if the user can view the document before downloading it.

I've hunted around but found nothing except extension specific posts.

Any help appreciated

There are three ways to present content to a user:

  • Content-Disposition: Attachment — which tells the browser that it should be saved rather then displayed
  • Content-Disposition: Inline — which tells the browser that it should be displayed (either natively or with a plugin) rather then saved
  • Via scripting / applets / Flash / etc — in which you provide program code to render the content

The first two approaches are generic HTTP. The third has to be handled on a file-type by file-type basis since you need different renderers for each kind of content.