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

設置屬性 PHP PDO setAttribute

設置屬性 PHP PDO s...

PDO::ATTRCASE:強制列名為指定的大小寫。 PDO::CASELOWER:強制列名小寫。 ...

javascript如何取得檔案的副檔名?

javascript如何取得...

var filenamea = "aaa"; alert(getFileExte...

PHP清空陣列函數

PHP清空陣列函數

pexelsphoto5555 unset(arrar) 將整個陣列清空,但之後如果再加入元素,其 ...

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