Problem with opening pdf file in site - apache

I have pdf file in serwer and link to it. In local host when i click on link pdf file display in site. On server I've got popup with asking to download file. How to change type from application/octet-stream to application/pdf to display pdf normal on site?
Here is screen after clicking on link:

The reason that the listed solutions are reported not to work half the time, is because using the default MIME association or setting the Content-Type header in <Files> or <FilesMatch> (for the PDF file extension) will have no effect on PDF files that are dynamically transferred via PHP code (i.e., readfile())...
To force a PDF to open in the browser rather than downloading, you should use LocationMatch instead:
<LocationMatch "\.(?i:pdf)$">
ForceType application/pdf
Header set Content-Disposition inline
</LocationMatch>
This way it picks up on transfers that are not direct from the file-system.

If it a unix server add an entry for pdfs in /etc/mime.types, if it's a Windows server, add a mime type in IIS.

Problem solved with using solution from this site:
http://www.thingy-ma-jig.co.uk/blog/06-08-2007/force-a-pdf-to-download
Thanks Joost Evertse

Related

-Apache- files from "website" not UTF8

ok, lets start from scratch. I just realized this is apache and not phpmyadmin, my bad.
Anyway, I needed some sort of file storage accessible through the web. I deleted the index.html to list the other files in /var/www. Now if I open the json file (UTF8 w/o BOM) in the browser, the special charakters like ä,ü,ö are not correctly displayed (normal chars are). If I download the file, all is correct on my system.
So the file itself is fine, but the stream from apache to the web is not in UTF8, or something like that. And that I would like to change.
I need this for an android app, where I parse the content of the json file with volley lib. But there it also gets the special charakters wrong.
hope this is more usefull than befor. my apologies for that.
The only thing that is wrong is that your browser doesn't know it should interpret the UTF-8 encoded JSON file as UTF-8. Instead it falls back to its default Latin-1 interpretation, in which certain characters will screw up, because it's using the wrong encoding to interpret the file.
That is all. The file will appear fine if it is interpreted using the correct encoding, UTF-8 in this case.
Use the View → Encoding menu of your browser to force it to UTF-8 and see it work.
Why doesn't the browser use UTF-8? Because there's no HTTP Content-Type header telling it to do so. Why is there no appropriate HTTP header set? Because you didn't tell your web server that it should set this header for .json files. How do you tell Apache to do so? By adding this line in an .htaccess file:
AddCharset UTF-8 .json

Server side: detecting if a user is downloading (save as...) or visualizing a file in the browser

I'm writing an apache2 module
by default and when viewed in a web browser, the module would only print the first lines of a large file and convert them to HTML.
if the user choose to 'download as...', the whole raw file would be downloaded.
Is it possible to detect this choice on the server side ? (for example is there a specific http header set ?).
note: I would like to avoid any parameter in the GET url (e.g: "http://example.org/file?mode=raw" )
Pierre
added my own answer to close the question: as said #alexeyten there is no difference. I ended by a javascript code the alter the index.html file generated by apache.

HTTP 404 file not found error even the file exist in the webserver IIS6.0

I am having files in the server to be available for downloads. I am using IIS6.0. When I try to download the pdf file it say Http 404 file not found error. But I am having the file in the server. While googling I found we need to enable the mime type. can any one explain me what is it and get rid of this problem
This is easy enough to sort out
To enable globally on the all site hosted by this IIS instance
Open IIS Manager
Right Click the server name
Select properties
Click the MIME Types button
Click New
Extension is .pdf
MIME type is application/pdf
To add it only to a single site on the IIS instance
Open IIS Manager
Right Click the sites name
Select Properties
Choose the 'HTTP Headers' tab
Click the MIME Types button
Click New
Extension is .pdf
MIME type is application/pdf
Open Internet Information Service(IIS) Manager
Right click on your website
Select HTTP Header tab
You will find button to add MIME Types
This link might be helpful to you.
You will find help in the Microsoft Knowledge Base: http://support.microsoft.com/kb/326965

Apache .htaccess query

I am hosting a bunch of files on an Apache server. The files all have an extension of ".plugin" (i.e. filename.plugin ).
The files are actually zip files with the extension changed.
When downloading via Firefox the browser saves the file as "filename.plugin" which is great.
However when using IE it somehow knows this is a ZIP file and downloads it as "filename.zip".
The question is how do I force it to download with a ".plugin" extension ?
Try to force it to a Mime Type, maybe the IE see that the type is a zip, try something like:
AddType application/plugin plugin
in the httpd.conf or in the .htaccess

How can I get my website to display a .c file instead of trying to make the user download it?

My webserver is Apache (I don't have admin rights over it though).
In my www/ directory, I have some .c files I'd like to display to the user to view in their browser.
Currently though, the website tries to make the user download the files instead of simply displaying them.
How can I fix this? Is there some sort of .htaccess trick?
Putting:
AddType text/plain .c
in the .htaccess should work.
This happens because apache does not know how to handle the file type and delivers it untouched and unidentified. You browser sees that the file type is not identified, can't associate the file with an application, so tries to save it.
There are a couple of ways.. Reconfigure Apache to serve this file as a text file or Rename The File so apache handles the file like a text file.
If you would prefer to reconfigure Apache find the following line in your configuration and modify:
AddType text/html .html .TXT .c
This instructs apache to include identify the file upon transmission to the browser as a text/html file. Note that .TXT may be there.
If you don't have access to the configuration, rename the file as FILE.C.TXT. Chances are, apache is already configured to server out text files. Note that this requires the .TXT to be specified as an txt/html handler and may not be on by default. Doing this will give you a quick test.
Good luck...