I am accessing this URL with my android device and the pdf download starts downloading automatically, without asking me to open the pdf vieth the pdf viewer.
This works in other websites.
I am the developer of the website. I set up the header to application/pdf. Any idea what can be the problem? Thank you.
Ok, I identified the problem and found the workaround.
It seems that the native android browser in not very intelligent. In fact, when a file is dowmloaded, the header of the file is not checked. The browser checks only the extension of the file in the url.
In my url, at the end we had /pdf, so no extension was found. By renaming the end of the url to xxx.pdf, the browser was able to recognize the file as a pdf.
Related
I am using TCPDF to generate the PDF, when I open a PDF file on my browser within the application use, with URL viewDocument.php look like these,
And when it is downloaded, view downloadDocument.php
Not understanding why this problem is occurring, really do not understand.Please Help!!
Does anyone know how to serve my own files like TestFlight or Diawi ?
I used Firefox web developer tools to let me pick up the header information (from Diawi) then used PHP to set header and readfile to output but this has failed - I have also tried to just reference the file via my web browser but each time my iPad Safari tells me it cannot download this file.
Don't try to download .ipa file directly, you should create manifest.plist file that contains app information and create a link to this .plist file like below.
Than go to this link via safari.
Manifest file should like this : https://gist.github.com/hramos/774468
And you link should like this: itms-services://?action=download-manifest&
url=http://example.com/manifest.plist
You can check this page:
Wireless AdHoc Distribution
There are online tools that simplify this process of sharing, for example https://abbashare.com or https://diawi.com
Create an ipa file from xcode with adhoc or inhouse profile, and upload this file on these site.
I prefer abbashare because save file on your dropbox and you can delete it whenever you want
On my Apache webserver i can server PDF files directly in the Browser with a simple Anchor link like:
Click to display PDF
This Works fine.
Now, i've got a lot of PDF's i want to Protect. So i moved them all outside the Web folder, and are serving them through a PHP download program - i called it download.php
To be sure that the pdf files are not downloaded as "download.php" i have to set the Content-Disposition Header to 'inline;filename="mysample.pdf"'. Inline because i want to open it in the Browser.
No Problem, all works fine. the files are downloading fine on Windows and Apple Browsers and are displayed IN the Browser, just like when its served directly from the Apache Server.
But my download.php doesn't work with Android Browsers... It's always just downloaded but not opened in the browser. You have to find the file in your messages and open it separately. When served directly from Apache it IS opened in the Browser.
It seems to be connected with Content-Disposition Header im setting in my download.php, because this is the only difference i see in the headers when download direct and indirect.
Anybody had the same problem?
Thanks
Per
I am using ajax to post to a function that creates a PDF document through TCPDF.
Normally, I would just do a normal post to the function, and that would output the PDF, allowing the user to download teh pdf file. My understanding, however, is that this doesnt work with ajax, and that I instead need to save the pdf file on the server, and then return the url of the file to the ajax call.
Once I have the url, then I can do something like
window.location.assign(url/to/my.pdf);
Ok, so this all works fine, but its not great. Firstly, the pdf doesnt open in a new window (i.e. it currently opens in the same window), and secondly, I'd prefer to force the user to download the file rather than it opening in the browser.
Are there any other alternatives?
If you're using Apache for your web server, then you can add the following to an .htaccess file in the folder where your PDF files are generated to force a download.
<Files *.pdf>
ForceType application/pdf
Header set Content-Disposition attachment
</Files>
You could pass the generated PDF through PHP and set additional headers to force browser to download the document. See php force download extension.
I guess you can make these headers to be set by Apache automatically as well (e.g. for PDFs in particular folder).
I am working on a project which creates a KML File (just like an XML file, but used for Google Earth). Whats interesting is when I link to the newly created file, on my local machine, running XAMPP, the file is downloaded automatically, however when I move it to my web server (Linux, Fedora 8 on EC2) the link just loads the KML file in the browser as if it was an HTML file.
How can I force it to download the file instead of viewing it in the browser?
Here's how to link is displayed with PHP,
echo "<a href='$currentTime.kml'><img heigth=\"15px\" width=\"13px\" src=\"images/KML_Icon.gif\" /> Download</a>";
Any advice would help, thanks!
What you need to do is to specify the headers so the Browser knows what to do with the information that you are sending. So before you send anything to the browser you will need to specify the headers.
If you are linking to a specific file, then you will have to create a little "download manager" that will do this for you.
<?
header('Content-disposition: attachment; filename=the-name-you-want-them-to-see-in-their-download.pdf');
header('Content-type: text/xml'); //Since KML files are based on XML this is probably the best Content type to send to the user.
readfile('the-file-you-want-to-present')
?>
That should do it.
Thank you for your guys' input, but Oded had the answer regarding the mime types.
On the server there's a file called mime.types which didn't contain the mime type for a KML file, I added in
application/vnd.google-earth.kml+xml
And it now downloads the file instead of loading it in the browser, by the way apache needs to be restarted once you have made the changes.
I had this a long while ago, I used a method similar to this:
http://webdesign.about.com/od/php/ht/force_download.htm