I want to write a jq plug-in that allows the user to select a local file and then read the file. How can I select the file and then read it directly or get the absolute path? Both are acceptable.
However, after searching for a long time, I found that the absolute path problem is difficult to obtain due to security issues. Please provide solutions.
If you just want to read the file content for processing, you don’t need to know the local address. You only need to use the File API of html5. If you want to display something through the address, you should upload it to the background and return a network address.
You can check out my detailed summary:
Advanced JavaScript Learning (3) - File Operations Based on HTML5 File API
is not because the absolute path problem is difficult to get due to security issues, so change is difficult to impossible .
Getting the local path is not possible, you can look at the File API
Upload to the background for parsing and then send it back to the front-end. The front-end js cannot read the file content directly