简体   繁体   中英

How can i read string from local file?

How can i read files by specifying "file path" by using javascript?

i am lazy to manually click input button and select them every times.

i also tried to cheat it by use JQUERY to do but it seems like jquery can not modified input value.

Any other suggestion to dealing with local file is welcome. Thank you

For security reasons javascript is running in a sandbox environment inside the browser and you cannot access the file system on the client computer.

If that was possible by only navigating to a website, the author of this website could access any file on the client computer. That's not something that people browsing the internet usually want.


UPDATE:

Using the HTML5 File API you have the possibility to access the contents on the client of files that were explicitly loaded by the user in an <input type="file"> fields or were for example drag and dropped from the desktop. But the user must explicitly perform this action. You cannot access arbitrary files.

How can i read files by specifying "file path" by using javascript?

You can't.

i am lazy to manually click input button and select them every times.

You have to. That is how the user gives the web application permission to access the files.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM