简体   繁体   中英

Internet Explorer is saving a TXT file as HTM when saving the target

I had a

<a href = ".\<something>.txt"> Download </a>

When I Save the target in Chrome, it saves as TXT. However, when I do the same in IE, it opens a window with the file format changed to HTML.

How do I fix this? Is it a configuration issue on browser or a code issue ?

I know that IE is a bit problematic in using some HTML5 elements

I've run into a similar problem myself with PDF downloads, that were saved as html files, while it was still a PDF-file. In my case I used a PHP-function to create the file and forgot to exit the code after providing the download to the frontend, which resulted in the script returning a html-result with the filetype ".pdf.html".

I don't know if it's the same case for you, but after declaring the header-data (Content-Type and Content-Disposition) let the script exit and check if that fixes the issue.

在服务器的响应标头中设置内容类型

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM