Apache Config Mime Types: xlsx files are being interpreted as zip files on download, why? - apache

Background: For some reason, whenever a user tries to open an xslx (excel 2007) file from our intranet using MSIE, the file download dialog interprets it as a "zip" file.
Admittedly, xslx files really are zip files, but we don't want that behavior. Just open in Excel, please.
Question:
Firefox, OTOH, opens the files normally. Is it possible that the fault is my apache configs? or is this a client-browser-only issue?

You must add some new MIME-TYPES on the web-server-side.
See the comment-thread on this windowsnerd.com page (from 2009):
Add this to a .htaccess file and throw it on your site: AddType
application/vnd.openxmlformats .docx .pptx .xlsx .xltx . xltm .dotx
.potx .ppsx
Should fix many of the problems.
Alternatively, you can add this to the mime.types file located in the config directory of your Apache web server
application/vnd.ms-word.document.macroEnabled.12 .docm
application/vnd.openxmlformats-officedocument.wordprocessingml.document docx
application/vnd.openxmlformats-officedocument.wordprocessingml.template dotx
application/vnd.ms-powerpoint.template.macroEnabled.12 potm
application/vnd.openxmlformats-officedocument.presentationml.template potx
application/vnd.ms-powerpoint.addin.macroEnabled.12 ppam
application/vnd.ms-powerpoint.slideshow.macroEnabled.12 ppsm
application/vnd.openxmlformats-officedocument.presentationml.slideshow ppsx
application/vnd.ms-powerpoint.presentation.macroEnabled.12 pptm
application/vnd.openxmlformats-officedocument.presentationml.presentation pptx
application/vnd.ms-excel.addin.macroEnabled.12 xlam
application/vnd.ms-excel.sheet.binary.macroEnabled.12 xlsb
application/vnd.ms-excel.sheet.macroEnabled.12 xlsm
application/vnd.openxmlformats-officedocument.spreadsheetml.sheet xlsx
application/vnd.ms-excel.template.macroEnabled.12 xltm
http://www.webdeveloper.com/forum/showthread.php?t=162526

The reason is IE's strange MIME sniffing behaviour: http://msdn.microsoft.com/en-us/library/ms775147.aspx. It basically tries to determine to the file type of a file by looking into its contents, somehow like Linux's file tool.

Related

Firefox removes extension on files when specific download folder is set on options

I'm having a problem downloading files on Firefox 62.0.2 (64-bit) or Firefox Developer Edition 63.0b9 (64-bit). On Internet Explorer works fine.
I've an admin panel with two buttons to download PDF's. When I click the buttons download pop-up shows and tell me to open the file or save it (and recognize the file as a PDF file). If I choose to open it it opens, but if I've set in the options to save the files on a specific folder, the file is saved with no extension. But if I've set on the options to specify the folder to download everytime, the file it's saved with the extension.
Here you can see the pop-up when it opens:
Then, If I've set on options download always to a specific folder:
But if I've set on the options to specify a folder everytime I download a file:
The file it's saved with the extension. On the code I've set the headers:
response.setHeader("Content-Type:", "application/pdf");
response.setHeader("Content-Disposition", "attachment; filename=\"desglose.pdf\"");
The URL to access to this resource it's:
#GetMapping(value = "/{id}/desglose")
#Secured(AuthoritiesConstants.ADMIN)
And after read this link Firefox cuts extension on files I don't know where it's my mistake. What I'm doing wrong?
Regards.
Ok, while reading the code after had copied here the lines, I noticed that after the function in other class there was a line with:
response.setHeader("Content-Disposition", "attachment");
which was overriding the value:
response.setHeader("Content-Disposition", "attachment; filename=\"desglose.pdf\"");
and was causing the problem. After remove the line response.setHeader("Content-Disposition", "attachment"); the downloads work fine.
Regards!

Download the .exe file instead of .htm file

My website has an option of downloading a .exe file. I uploaded this .exe file in dropbox and use the shared link in my website for the users to download the file.
I use href in my index.php page to create a link to that file:
<a href="https://www.dropbox.com/s/........./File.exe?dl=0" download="File">
But when users click that link in my website it downloads the .htm file. The users need to click this .htm file again which then leads to the download of the .exe file. At times users also get the error "There was an error downloading your file." while downloading the file from dropbox. I would like to know how to get the link to download the .exe file directly. Thanks!!!
When you use ?d1=0 at the end of your file path it will show the file in a preview page. Try changing it to ?dl=1to force the download.
https://www.dropbox.com/help/desktop-web/force-download

automatically place downloaded files in folder bsed on downloads extension suffix

I’m making a simple web browser for work eeh, what I’d like to know is if its possible to save a file of a particular extension to a particular file.
I currently use google chrome when downloading a file it places this (regardless of extension) in a downloads folder without asking where I ant to download this too.
I want to achieve the same except that downloads with the extension .dwg are placed automatically in a folder named DWG DOWNLOADS…
How to achieve this in vb.net?
In any browser you have a config section.
In Firefox you have browser.download.useDownloadDir;true and browser.download.folderList;1
you can add your own config to allow different saved folder paths and dynamically modify them depending on the extension of the file you uploaded.
See a complete list of the web browser config with about:config in address bar.
Not real sure what you are asking, but if you are actually making a web browser just check the extension of the file you are requesting to download. If the extension is ".dwg" then save the file to the folder you want.
If you are wanting to automatically move Google Chrome downloads to a different directory, you can use a FileSystemWatcher to monitor for new files in Chrome's download directory and move them to another folder based on each file's extension.

Trying to create .htaccess file using ftp doesn't work

I want to create a .htaccess file in a specific directory. I'm using Notepad++ and their plug-in for FTP (NppFTP). I'm able to create any other files and see them in the folder but when I try to create a .htaccess I don't see that file in the directory. I get no errors, it is like nothing happened.
I tried to create this file using an FTP program and it showed the file and right away it disappeared. My guess it is because this is a special file used by the system and prefixed by a (.)
What is a way to edit that file?
This is probably because your ".htaccess" file is a hidden file and your system is set up to no display hidden files.
Have a look in your Notepad++ settings if there's an option to make hidden files visible/unhide.
In addition to that check the windows folder options for that option!
switch on showing hidden files in your ftp client

.xlsx downloading issue

I have generated .xlsx reports on server, and page with direct links to these reports.
When user clicks a link, report file is downloaded, but file extension is changed to .xls.
Therefore, I can't open file correctly, only after changing of extension.
Problem occurs in IE, Firefox correctly downloads file, and Chrome saves file with name "File.xlsx.xls"
What can cause such behaviour? Any help appreciated.
Problem fixed with setting of mime-type "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" for .xlsx files