I'm generating an excel file from PHP with PHPExcel library and when it's filled with all the data it's is automaticaly downloaded, the problem is that chrome only shows column headers without data, meanwhile firefox downloads de file correctly.
In chrome's console appears this message "Resource interpreted as Document but transferred with MIME type application/vnd.openxmlformats-officedocument.spreadsheetml.sheet:"
Anyone may know what can cause this problem? Thanks
Related
I try to use this code to download files from my database, however, when I try to open the file, I get following errors:
when downloading file type 'docx':
Word documents are stored with the type: 'application/vnd.openxmlformats-officedocument.wordprocessingml.document' (not visible on the screenshot). I believe this is correct
I solved the bug when trying a bit different code:
Downloading jpg,doc,ppt files with php are corrupted
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.
I'm using yii with html2pdf version 4.03 for downloading pdf documents in my project. The pdf documents consist of tables with many rows because they are reports. In my localhost, the download is fine. But when I do that in remote server, it can't be downloaded.
I used Firefox to download it. When I downloaded it, it prompted an alert message saying that I can't download because the source file cannot be read. When I force to download it (by pressing refresh button in firefox's download list), the pdf file is there. When I tried to open it, it says that the file is corrupted.
If I delete a few rows, it can be downloaded just fine. Strangely, even if I didn't delete the rows, they are still in one page. So the problem shouldn't be about "table row that doesn't fit in one page", should it?
What could be the problem? Could anyone help me with this please?
UPDATES
when I print it in browser instead of downloading, firefox prompts an error like below:
Content Encoding Error
The page you are trying to view cannot be shown because it uses an invalid or unsupported form of compression.
Please contact the website owners to inform them of this problem.
Still don't know how to solve this though...
Save the generated pdf, open it in text editor, and see what error message is there.
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'm seeing some strange behavior from some dynamically generated PDFs using the TCPDF library in PHP.
Standard lamp stack-- however, if you try to open the PDF from Windows with Acrobat Reader, it gives an error that the "file is damaged and could not be repaired". From Mac, Linux, etc. the file works fine, and opens fine. It also opens fine in Google Docs-- so clearly the PDF itself is ok.
Is it possible that the mime type (application/pdf) is causing problems in Windows?
Thanks
What browser on Windows? All? Or just one? My initial gut instict, is that the Windows browser is ignoring the encoding IF the content is being gzipped (Ignoring the Content-Encoding header). That's if you're even sending that header.
Open the file you downloaded in some text editor (Notepad, etc). The first few characters of the file should be %PDF-1. with another number after it. If it's not at the beginning, check to see if the file is gzipped (rename the file to blah.gz, and then run it through gzip to try to decode it). If that worked, then your problem is the browser ignoring the encoding.
IF it is ignoring the encoding, you need to not gzip the output of that PHP file. How you do that will depend on your server configuration.
Oh, and the application/pdf is the proper mime type. And the mime type is not your problem, since Acrobat is at least trying to open the file...