Customizing SMF > Tips and Tricks

View .txt files instead of Saving them.

<< < (2/2)

Elijah Bliss:

--- Quote from: [Unknown] on April 22, 2005, 08:06:12 PM ---Alright, find this in Display.php:


--- Code: --- header('Content-Disposition: attachment; filename="' . $real_filename . '"');
header('Content-Type: application/octet-stream');
--- End code ---

Replace with:


--- Code: --- header('Content-Disposition: ' . (substr($real_filename, -4) === '.txt' ? 'inline' : 'attachment') . '; filename="' . $real_filename . '"');
if (substr($real_filename, -4) === '.txt')
header('Content-Type: text/plain');
else
header('Content-Type: application/octet-stream');
--- End code ---

But, I still think the browser has more elegant support for this.  Meaning, if I click on an attachment WITHOUT making the above change, I get a dialog that gives me the option to "Open" or "Save" the document.
-[Unknown]

--- End quote ---

Not in Safari.

[Unknown]:
So use a better browser :P.

-[Unknown]

Elijah Bliss:

--- Quote from: [Unknown] on April 22, 2005, 09:39:01 PM ---So use a better browser :P.

-[Unknown]

--- End quote ---

Hey, Safari rules! lol. You never read a complaint from me about poor rendering in Safari, actually, that's a big reason why I like SMF, it looks really good Safari.

JesseTyler:
Thanks Unknown. It works perfectly now. :D

Navigation

[0] Message Index

[*] Previous page

Go to full version