1

I selected file and put it in state - everything about file object work properly but the but the webkitRelativePath is null ,

     <input type="file" onChange={changeHandler} id="main_img" name="img" style{{display:'none'}} webkitdirectory  />//this my input

state{//this is my state
  name:"1112.PNG"
  lastModified:1645438409236
  lastModifiedDate:Mon Feb 21 2022 13:43:29 GMT+0330 (Iran Standard Time)
  webkitRelativePath:""
  size:1158291
  type:"image/png"
  arrayBuffer:ƒ arrayBuffer() {}
  slice:ƒ slice() {}
  stream:ƒ stream() {}
  text:ƒ text() {}
}

this object is that get from input-- why webkit is empty ?

1 Answer 1

1

The short answer is, you can't get full path of a file with JavaScript. For security reasons this is not allowed in most browsers.

webkitRelativePath only works in Chrome. This allows a user to select a folder instead of files, and every single file is read recursively. The webkitRelativePath contains the relative path of the file within the hierarchy.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.