Reading files from hard drive with javascript

后端 未结 3 1172
南方客
南方客 2021-01-23 20:05

My application creates .xml files and stores them on the user\'s hard drive; there is a default folder that I set in the web.xml to store the files, le

3条回答
  •  挽巷
    挽巷 (楼主)
    2021-01-23 20:20

    As stated, you cannot access a file on the filesystem strictly through Javascript. You could, however, use the input file type to upload the file to your server and then read it:

    
    

    Then, you can access it via the $_FILES global in PHP - other languages also provide this functionality through other means. Please note, again, that there is absolutely no way to access a file that is on someone's filesystem with Javascript without their consent (i.e. using the file input type). That would be a huge security risk - imagine going to a page and having it wipe your whole D:/ drive.

提交回复
热议问题