jQuery: read text file from file system

前端 未结 10 2499
再見小時候
再見小時候 2020-11-30 10:09

I am trying to read a text file using jquery, like this:

// LOAD file and split line by line and append divs
$.get(\'myFile.txt\', function(data) {    
    v         


        
10条回答
  •  庸人自扰
    2020-11-30 10:40

    This doesn't work and it shouldn't because it would be a giant security hole.

    Have a look at the new File System API. It allows you to request access to a virtual, sandboxed filesystem governed by the browser. You will have to request your user to "upload" their file into the sandboxed filesystem once, but afterwards you can work with it very elegantly.

    While this definitely is the future, it is still highly experimental and only works in Google Chrome as far as CanIUse knows.

提交回复
热议问题