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如何設定HTTP安全標頭?

PHP如何設定HTTP安全標...

PHP該如何將以下安全標頭添加到網站? XFrameOptions  防止點擊劫持攻擊 XXSSPr...

PHP Caching Headers

PHP Caching He...

pexelsphotospeed 最近測試平台系統執行速度,老實說測試的有點無力~ 總覺得能做的可以...

使用.htaccess關閉特定文件的緩存

使用.htaccess關閉特...

以特定檔案為例 <Files page.php> FileETag None Header unse...

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