I have a link in my page :
View PDF
The problem is that when the link is clicked, Instead of viewing the content of the file in the browser, the file is downloaded .
Any ideas what's wrong?
ps : I have Mozilla FireFox 3.6 & Adobe Reader Installed
Make sure you use the correct mime type (application/pdf), and the Content-Disposition: inline header.
Check your webserver is providing the correct MIME type for the response - it should be application/pdf
Related
I am using joomla 2.5 with ROXBOX plugin and using this showing the PDF's in lightbox. I am facing problem when user configured Firefox auto download PDF files.
When Firefox configured as save PDF instead of open it in browser the light box stays blank and file started download. As we can not have control on browser, is there any way show any message when Firefox auto download for PDF is enabled?
Please Help!!
I assume you want the PDF to display in the browser, rather than forcing a download. If that is the case, try setting the Content-Disposition header with a value of inline. and 'Content-type to application/pdf.
header('Content-type: application/pdf');
header('Content-Disposition: inline; filename="the.pdf"');
You can use PHP to set header as shown above.
i am trying to make a download link in html that is given like this for a PDF Book
Download
but problem is that when download link is clicked it opens online version of pdf , does not offer download , i did google and found same way to add download link , any one can guide me with it please whats wrong here
As of late 2018, clicking the link won’t trigger a download if the resource to be downloaded wasn’t served from the same origin or same server. Apparently, this is restriction is a security measure.
You can download the content in browser and make it downloadable, you can check the below url
https://medium.com/charisol-community/downloading-resources-in-html5-a-download-may-not-work-as-expected-bf63546e2baa
you can try this
Download
HTML5 defines the download attribute, which forces the browser to prompt the user a download dialog for the resource instead of navigate to it.
Here is the support across the different browsers: http://caniuse.com/#feat=download.
Its not the problem with your script, instead its your browser that has pdf plug-in and displays you the content file directly.You can just save the page (Press CTRL+S) and it would be saved as .PDF file.
Thanks.
The HTML5 download attribute is only supported by Chrome and firefox... Try this :
Download
Download.php
header("Content-disposition: attachment; filename=http://www.mydomain.org/pdf/book.pdf");
header("Content-type: application/pdf:");
readfile("http://www.mydomain.org/pdf/book.pdf");
if you want to download the pdf in next tab with current website intact then use following code:
Download
My Firefox extension not loading on browser.
I uploaded it my server but when i clicking that link , it's not loading my browser. I have been seen just content codes.
How can i change content type as application/x-xpinstall ?
http://www.alisverisbook.com/zamantunelikaldirma/install.php?type=firefox
images:
Output a Content-type header in "install.php" prior to reading the file contents to the browser.
header("Content-type: application/x-xpinstall");
I'm building a web app with PHP that uses Excel Writer (XML) for PHP to create an Excel file that the user can download. I've taken a look at the source code for the library, and all it does is echo the generated XML to standard output. Although the file being generated is an XML file, I specifically give it a name with a ".xls" extension so that after it's been downloaded the end-user can double-click it and it will launch Excel on their system and open the file successfully.
This works correctly when downloading the file with Firefox, Chrome and IE, but not with Safari. For example, if I set the name of the file to be 'File.xls', this is the name of the file that gets downloaded. But with Safari the name of the file ends up being 'File.xls.xml'.
The server is running Apache on Mac OS X. I thought that might matter as I'm guessing that the problem has to do with MIME types on the server, but I'm not at all sure. Perhaps I can do something with the link that appears on the page, or perhaps I need to edit a configuration file for Apache? Any help is appreciated.
You might be right, it could just be the MIME type that needs setting.
Try putting
header("Content-Type: application/vnd.ms-excel");
before the output code, that should force the browser to see the data as an Excel file.
If the code is setting Content-Type already and it's conflicting, then search the script for "Content-Type" and try changing it.
Also, if it's an XLSX file, then there's a different MIME type - application/vnd.openxmlformats-officedocument.spreadsheetml.sheet
I am using php's imagejpeg to save a GD image resource to a file, doing this:
imagejpeg($im, '../images/' . $image_id . '.jpg');
It works fine, but according to my browser, it tries to read the file as text/plain:
Resource interpreted as image but transferred with MIME type text/plain.
Is there a step before saving the file that I am supposed to do to make sure it's using the right mine-type?
I am using windows (XAMPP), could it be a Windows issue?
EDIT: nope. I just tested in a linux server.
As far as the actual displaying, it's just plain html .
My upload code is supposed to saves= the file as a plain jpeg in the server. It's just not saving it with the right mime type.
Thanks
AFAIK, the Apache server - in standard out of the box configuration - should sent content-type headers purely based upon file extension. Apache shouldn't even even be looking at the contents or how it was originally generated/stored.
On my out-of-the-box Apache2, the file conf/mime.types contains the line:
image/jpeg jpeg jpg jpe
which ought to do it, right?
Can you post a test-case, say, a simple html page with two img tags: one for your generated image, and one for a standard image that seems to work fine?
One last thought: Does it occur in all browsers? Maybe it's a browser issue, not a server one?
It sounds like you're dumping the contents of the file to the browser and not actually telling the browser what type of file it is. Try adding a Content-type header before you output your image to the browser:
header('Content-type: image/jpeg');
Are you sure you aren't using the wrong file-extension name?
Otherwise, just put an normal image in the server and make sure the mime-types are properly configured.
It could also be that your image data from the manipulation is corrupted.