Loading...

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

Temperature: 0 °C

Mark ChangMark Chang
var filename_a = "aaa.jpg";
alert(getFileExtension(filename_a)); //returs jpg

function getFileExtension(filename) {
/**/
}

使用String 的 split 方法
function getFileExtension(filename) {
return filename.split('.').pop();
}

以上紀錄。

 
https://innstory.com/story-javascript如何取得檔案的副檔名?-1882

Prev
 使用jquery判斷上傳檔案大小

Next
使用curl執行POST請求 

About the Author

Mark Chang

離不開電腦的宅男

Visitor message

Leave some footprints to prove that you visited me

Recommended reading

Author's other related stories

文件上傳過程中使用白名單、黑名單、或者MIME做認證

文件上傳過程中使用白名單、黑名單、或者MIME做認證

pexelsphotolock 是不是被資安的問題搞得很煩? 我想,在建置系統的過程中...

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

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

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

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

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

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

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