Home > database >  How to get the real file path in React
How to get the real file path in React

Time:02-04

    <input onChange={(event) => setFileName(event.target.value)} type="file" id="file_input" />

I use this function to get the file name, however it shows C:\fakepath\myfile.jpg.

I understand this is security reason, however when I upload the file. I need full path.

How can I get the full path by React??

CodePudding user response:

In any JavaScript executed in the browser, you cannot directly access the file system of the client's device. This is due to security restrictions imposed by web browsers to prevent malicious scripts from accessing sensitive information on the client's computer.

The term "fakepath" is used to replace the missing file path.

While as a developer this may seem like a restriction, as a user, you do not want websites having any form of access to your device's directory.

  • Related