[Answered ]-Can I force to display the file in browser rather than download it for a particular sub url?

2๐Ÿ‘

โœ…

What type of file are you working with?

This is used through the HTTP header. If the mime type is a certain type, the browser will decide whether to download or display it. You can also force downloading. The file type will help.

For text files, set the content-type to text/plain. For JPEGs, set it to image/jpeg, and for PNGs set it to image/png. This should overwrite any attachment values Django is setting.

๐Ÿ‘คTim

0๐Ÿ‘

You want to use the Content-Disposition header for this. It should any haggling over content-type.

http://www.ietf.org/rfc/rfc2183.txt

0๐Ÿ‘

The default document type is declared under your server settings, not in how you link to the file. If you are under Apache try looking in httpd.conf for

DefaultType text/plain

If it says something different that may be your problem. text/plain should set all unknowns to download and be viewed in the browser as text.

EDIT:

I donโ€™t know any way of modifying this behavior through javascript as it has to be in the header of the file being downloaded.

๐Ÿ‘คHawken

Leave a comment