1. 程式人生 > >IE火狐下載檔案的字尾會根據MIME自動改變

IE火狐下載檔案的字尾會根據MIME自動改變

1、IE火狐下載時會根據Content-Type決定檔案字尾,以Excel為例

content-disposition: inline; filename=電量預測.xlsx;filename*=utf-8''%E7%94%B5%E9%87%8F%E9%A2%84%E6%B5%8B.xlsx
Content-Type: application/vnd.ms-excel;charset=UTF-8

雖然filename定義了這個Excel的字尾是xlsx,但是由於
application/vnd.ms-excel

對應的是xls,這兩個瀏覽器會吧檔名自動變更成“電量預測.xls”

2、如果http header沒有定義Content-Type

這種情況ie火狐都不會改變字尾,但是如果content-disposition是inling而不是attchment的話,在ie中會直接開啟,但是亂碼