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

Linux下查看版本號指令

Linux下查看版本號指令

lsbrelease a ssss5 其他指令查詢方式 [root@localhost ~]# un...

使用PHP mb_substr() 函式,擷取部分字串並記得使用UTF-8。

使用PHP mb_subst...

pexelsphotohello5 文字長度太長,一般來說我們可以使用DIV包住字串,再定義DIV的...

利用 .htaccess 限制可瀏覽ip來源

利用 .htaccess 限...

要如何限制某個資料夾內容只能給特定IP讀取? 這個部分其實可以透過.htaccess快速實現~ 首先...

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