How to get the contents of the directory from local PC in javascript

前端 未结 8 2335
轮回少年
轮回少年 2020-12-31 20:13

How to get the contents of the directory from local PC in javascript/jQuery? For example from C:\\Images

相关标签:
8条回答
  • 2020-12-31 20:39

    Javascript/Jquery does not have access to the local file system for security reasons. This is not possible.So try some server side base code.

    0 讨论(0)
  • 2020-12-31 20:39

    Now, some years later, accessing to local files works fine in Chrome AND Firefox (52.8, but update Firefox is easy). It works also with IE 11.

    <!DOCTYPE html>
    <html>
    <head>
    <meta charset="UTF-8">
    <title>files</title>
        <meta charset="utf-8">
        <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    </head>
    <body>
    <script>
    // Check for the various File API support.
    if (window.File && window.FileReader && window.FileList && window.Blob) {
      // Great success! All the File APIs are supported.
    } else {
      alert('The File APIs are not fully supported in this browser.');
    }
    </script>
    </body>
    </html>
    
    0 讨论(0)
  • 2020-12-31 20:44

    You could write a script using a technology like php, ruby, java which will list all files and then send this information via ajax to Your browser.

    But You can't do this only via javascript because of security restrictions.

    0 讨论(0)
  • 2020-12-31 20:46

    it is not possible to have javascript-access to the local file-system from the browser, and this is good so!

    0 讨论(0)
  • 2020-12-31 20:48

    here you can read local files by html5 and javascript using the file APIS

    http://www.html5rocks.com/en/tutorials/file/dndfiles/

    0 讨论(0)
  • 2020-12-31 20:53

    Javascript can't access the users drive. That would be a big security issue, wouldn't it? :D

    Instead, you need to use an other technology like flash or java-applets.

    0 讨论(0)
提交回复
热议问题