javascript判斷文件是否存在
1. 客戶端
script language="javascript"> function FileExist() { var sfso=new ActiveXObject("Scripting.FileSystemObject"); var fPath="[The path of the file]"; if(sfso.FileExists(fPath)) { alert("Exist"); } else { alert("Doesn't exist"); } } /script>
2. 服務(wù)器端
script language="javascript"> function FileExist() { var xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); xmlhttp.open("GET",FileURL,false); xmlhttp.send(); if(xmlhttp.readyState==4) { if(xmlhttp.status==200) alert("Exist"); else if(xmlhttp.status==404) alert("Doesn't exist"); else alert("Don't know"); } } /script>
感謝閱讀,希望能幫助到大家,謝謝大家對(duì)本站的支持!
標(biāo)簽:自貢 山南 銅川 白銀 吉林 臨汾 烏蘭察布 開(kāi)封
巨人網(wǎng)絡(luò)通訊聲明:本文標(biāo)題《javascript判斷文件是否存在實(shí)例代碼》,本文關(guān)鍵詞 javascript,判斷,文件,是否,;如發(fā)現(xiàn)本文內(nèi)容存在版權(quán)問(wèn)題,煩請(qǐng)?zhí)峁┫嚓P(guān)信息告之我們,我們將及時(shí)溝通與處理。本站內(nèi)容系統(tǒng)采集于網(wǎng)絡(luò),涉及言論、版權(quán)與本站無(wú)關(guān)。上一篇:jsp 生命周期詳細(xì)介紹