This would be REALLY helpful on a SMF forum i'm making. (Dealing with tons of txt files.)
Why can't you just click "open" instead of "save"?
I can tell you what to change, though.
-[Unknown]
Ok look.
I'd want it to be able to just attach the .txt file to the post. Then click on it and have it open like i'm viewing a .txt file directly. :p
Quote from: JesseTyler on April 21, 2005, 01:09:35 AM
Ok look.
I'd want it to be able to just attach the .txt file to the post. Then click on it and have it open like i'm viewing a .txt file directly. :p
Right-clicking doesn't work?
Alright, find this in Display.php:
header('Content-Disposition: attachment; filename="' . $real_filename . '"');
header('Content-Type: application/octet-stream');
Replace with:
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');
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. Choosing "Open" opens it in Notepad, which I like to use to view text files and even prefer to my web browser.
This change cannot make it automatically pick "Open" and use Notepad, and such a thing is not going to be possible from a webpage. However, it will make the web browser simply display the file instead of downloading it.
-[Unknown]
Quote from: [Unknown] on April 22, 2005, 08:06:12 PM
Alright, find this in Display.php:
header('Content-Disposition: attachment; filename="' . $real_filename . '"');
header('Content-Type: application/octet-stream');
Replace with:
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');
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]
Not in Safari.
So use a better browser :P.
-[Unknown]
Quote from: [Unknown] on April 22, 2005, 09:39:01 PM
So use a better browser :P.
-[Unknown]
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.
Thanks Unknown. It works perfectly now. :D