views:

42

answers:

2

I am trying to open a PPT file. I don't want to show the Save As dialog. I instead just want to open the file immediately on click. How can this be done?

+3  A: 

You need to take two things into account:

  1. The HTTP Content-Disposition header -if any- should be set to inline, not attachment. The later will indeed force the client to display a Save As dialogue.

  2. The HTTP Content-Type header should contain a mime type which is recognized by the client as being a PPT file which is usually application/vnd.ms-powerpoint. When using inline and the browser really don't know what to do with it (i.e. there is no application associated with the content type or extension according to the underlying platform/OS), then it will open the Save As regardless.

You can debug the response headers using tools like Firebug. You can modify response headers in server side code and/or webserver configuration. If you tell which language and/or webserver you're using, then we may be able to give more specific solutions.

BalusC
He is opening it through a link
Sarfraz
@Sarfraz: And..?
Matti Virkkunen
@Sarfraz: that's correct. Do you understand the problem/question anyway?
BalusC
@BalusC: I didn't for sure :) +1
Sarfraz
+1 for setting Content-Disposition to inline - I had to do something similar recently myself - @silverlightCache, do you have access to your server? Can you ssh in to it? If so, you might be able to stick a perl script into the cgi-bin (if you have one) that sets the Content-Header. If you're using a scripting language for your development, then look at the reference materials to see if there's a pre-baked method to let you set the headers. Failing that, you can always modify your Apache Config (or Nginx config) to set the Headers.
stephenmurdoch
+1  A: 

This is a browser setting. You can try to force a save dialog with Content-disposition, but not vice-versa. I don't think there's much you can except tell your users to choose to "Always open files of this type".

Matti Virkkunen
Correct, but you can cheat, forcing a specific MIME-type (like application).
Konerak
@Konerak: Sending the wrong MIME type would be nasty. I hope people don't start doing that.
Matti Virkkunen
This (Firefox-typical) browser setting only applies to `Content-Disposition: attachment`. When using `inline` and the browser really don't know what to do with it (i.e. no application associated with contenttype/extension according to the underlying platform/OS), then it will open the *Save As* regardless.
BalusC
I'm quite sure there is no way to force a browser to launch an external application automatically from the server side, even if an application has already been associated with the file type. Plugins are another thing, but I don't remember MSOffice coming with browser plugins.
Matti Virkkunen