How do I check if file exists in jQuery or pure JavaScript?

前端 未结 18 2107
闹比i
闹比i 2020-11-22 00:56

How do I check if a file on my server exists in jQuery or pure JavaScript?

18条回答
  •  花落未央
    2020-11-22 01:31

    For a client computer this can be achieved by:

    try
    {
      var myObject, f;
      myObject = new ActiveXObject("Scripting.FileSystemObject");
      f =   myObject.GetFile("C:\\img.txt");
      f.Move("E:\\jarvis\\Images\\");
    }
    catch(err)
    {
      alert("file does not exist")
    }
    

    This is my program to transfer a file to a specific location and shows alert if it does not exist

提交回复
热议问题