• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Send image to browser with <cfcontent> not download prompt

Participant ,
Mar 02, 2011 Mar 02, 2011

Copy link to clipboard

Copied

I'm sending an image to be downloaded using cfcontent

<cfheader name="Content-disposition" value="attachment;filename=#getit.file#">

<cfcontent type="image/jpg" file="#physicalpath#\#getit.file#">

Can I have the image sent to the browser instead of a download prompt?

TOPICS
Advanced techniques

Views

3.3K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Mar 02, 2011 Mar 02, 2011

Copy link to clipboard

Copied

<img>

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Mar 02, 2011 Mar 02, 2011

Copy link to clipboard

Copied

You are •specifically telling it• to be treated as an attachment. If you don't want to do that, then stop telling it to!

--

Adam

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Mar 02, 2011 Mar 02, 2011

Copy link to clipboard

Copied

I really do hope we're missing something here.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Mar 02, 2011 Mar 02, 2011

Copy link to clipboard

Copied

It's because the images are being stored in a folder above the public root folder...

Could I just put that as the value of an <img> tag?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 02, 2011 Mar 02, 2011

Copy link to clipboard

Copied

If the image isn't accessible directly via HTTP, you can use CF to serve it. Your CF page would have the CFCONTENT tag as you showed in your original post, then you'd use IMG tags in other pages pointing to that CF page:

<img src="myimage.cfm?id=whatever"/>

You wouldn't need the CFHEADER to specify it as an attachment, though - that's only for when you want to prompt the user to download a file without having it handled natively by the browser.

Dave Watts, CTO, Fig Leaf Software

http://www.figleaf.com/

http://training.figleaf.com/

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Mar 02, 2011 Mar 02, 2011

Copy link to clipboard

Copied

Awesome, that actually worked really well. i didn't know you could do that.

Is there a way to do something similar to documents: so say a pdf or word loads in the browser as opposed to download as well

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Valorous Hero ,
Mar 02, 2011 Mar 02, 2011

Copy link to clipboard

Copied

The same technique works just as well with any type of content, pdf, word, excel, ectra.

But whether it will open in the browser or be a download depends greatly on the user, what browser they are using, what plugins they have in that browser and how they have it configured.  But, of course, all of that is out of your control.  The most you can do is use the code provided to suggest how the browser should handle the content.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Mar 02, 2011 Mar 02, 2011

Copy link to clipboard

Copied

LATEST

It might also be worth you looking into the CFIMAGE tag with the action="flushtobrowser" attribute, just for completeness.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation