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.
阿神2017-06-12 09:35:01
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
淡淡烟草味2017-06-12 09:35:01
is not because the absolute path problem is difficult to get due to security issues, so change is difficult to impossible .
typecho2017-06-12 09:35:01
Getting the local path is not possible, you can look at the File API
三叔2017-06-12 09:35:01
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