判断本地文件

function ReportFileStatus(filespec) { 
   var fso, s = filespec; 
   fso = new ActiveXObject("Scripting.FileSystemObject"); 
   if (fso.FileExists(filespec)) 
      s += " exists."; 
   else  
      s += " doesn't exist."; 
   return(s); 
}  



判断网络文件

$.ajax({ 
   url:'http://www.example.com/somefile.ext', 
   type:'HEAD', 
   error: function() { 
       //file not exists 
   }, 
   success: function() { 
       //file exists 
   } 
});