When I click link to log file(I have a log of links like that) the firefox opens the file, but I want to just save it(like I do with PDFs). However I dont have log file defined as Manage File Type. How can I add log files there?
2 Answers
Firefox, like all other browsers, uses the HTTP Content-Type
header to decide how to handle the page. In your case, the log file is served as text/plain
, which is handled by Firefox internally. Whether the URL ends in .txt
or .log
does not matter.
If you have access to the web server, you could reconfigure it to serve .log
files as, for example, application/x-log-file
- either by editing .htaccess
if the server is running Apache, or by reconfiguring the server itself.
If you don't have access to the web server's configuration, it's also possible to write a small script (in PHP or any other language) that would set headers and output the desired file:
<?php
if (isset($_GET["file"])) {
header("Content-Type: application/x-log-file");
readfile(basename($_GET["file"]));
} else {
echo "<ul>\n";
foreach (glob("*.log") as $name) {
echo '<li> <a href="?file='.htmlspecialchars($name).'">'
.htmlspecialchars($name)."</a>\n";
}
echo "</ul>\n";
}
-
cool idea, however If I make page like this <a href="bla.pdf">a</a> and click it the firefox saves the pdf to the file. he recognize the extension. I think there should be a way in adv ff options to add new recognizable types.– IAdapterDec 20, 2010 at 6:03
-
@01: It doesn't. Your webserver tells it that the file is of type
application/pdf
. See for yourself. Dec 20, 2010 at 16:24
I got this to work with .rdp
files with the following links: