Reputation: 1393
In ColdFusion I have code to open or download a file:
<cfif FileExists('#session.exploc#/#attname#')>
<cfset typeatt = FilegetMimeType('#session.exploc#/#attname#')>
<cfheader name = "Content-Disposition" value="attachment;#session.exploc#/#attname#">
<cfcontent type="#typeatt#" file="#session.exploc#/#attname#">
</cfif>
This gives a standard open/download window.
I would prefer a window which just allows the user to open the file, and does not provide a download. Is there a way to do that?
Alternatively, I am happy to open the file in the browser, but since I don't know the filetype in advance I'm not sure how to do that.
Upvotes: 1
Views: 428
Reputation: 29870
This is not a function of <cfcontent>
per-se. All <cfcontent>
handles is the MIME-type of the response, the content of it (it can reset it for example), and a few other bits and pieces. It's all about the nature of the content returned by the CFML server.
This is all fairly clear in the docs for <cfcontent>
:
Some file types, such as PDF documents, do not use executable code and can display directly in most browsers. To request the browser to display the file directly, use a cfheader tag similar to the following:
<cfheader name="Content-Disposition" value="inline; filename=name.ext">
IE: what you want to be doing is to set the Content-Disposition
header with a value of inline
to tell the browser to potentially inline the document, if if has the capabilities to do so.
Upvotes: 2