2010-12-05 73 views

回答

8

要檢測是否選擇了一個文件,你可以找出文件輸入的長度

$("#bCheck").click(function() { // bCheck is a input type button 
    var fileName = $("#file1").val(); 

    if(fileName) { // returns true if the string is not empty 
     alert(fileName + " was selected"); 
    } else { // no file was selected 
     alert("no file selected"); 
    } 
}); 
相關問題