Loading...

點選檔案下載卻直接執行開啟

Temperature: 0 °C

Mark ChangMark Chang
author_tools

遇到一個情況。

使用者開啟瀏覽器點選某個連結檔案時,不會執行下載而是直接開啟檔案。

原本如果只是圖片或是PDF檔案來說原則上是沒有問題,因為瀏覽器也可以支援開啟

但如果是RAR或者是ZIP又或者是一些瀏覽器無法識別的檔案直接開起就有可能會造成顯示亂碼的問題。

其實只需要加上一個download的屬性就可以解決。

如下範例:

<a href="路徑" download="filename.rar">點選下載</a>

以上紀錄~

#故事  #download  #造成顯示亂碼  
https://innstory.com/story-點選檔案下載卻直接執行開啟-2788
html5

Prev
 青少年

Next
如何將_a_href_禁用 

About the Author

Mark Chang

離不開電腦的宅男

Visitor message

Leave some footprints to prove that you visited me

Recommended reading

Author's other related stories

RPO(Relative Path Overwrite)相對路徑覆蓋攻擊

RPO(Relative P...

首先,先來用例子說明何謂「相對路徑」何謂「絕對路徑」。 例如你有一個網址為http://www.de...

js判斷字母是否為大小寫

js判斷字母是否為大小寫

使用JS來判斷字串裡是否含有大寫字母或小寫字母。 //判斷是否含有大寫字母 function chk...

使用curl執行POST請求

使用curl執行POST請求...

curl命令是一個利用URL規則在命令行下工作的文件傳輸工具。 支持文件的上傳和下載。 這邊範例使用...

Please select an option

error

Hi, thank you for your participation, but you cannot vote repeatedly~

Join innstory now and start recording your story.

"Innstory" is a place to store stories. We are committed to becoming a warm platform. Deepening the bonds between people is our direction.
We are convinced that the blockchain between people is not just a cold calculation. Join us now.

Wrong format