Get all images from local folder

后端 未结 2 670
走了就别回头了
走了就别回头了 2021-01-02 06:23

I need a way to get all the images from a local folder for a presentation that will also run locally. There will be no attempt for a server to take the images from a local f

2条回答
  •  既然无缘
    2021-01-02 07:04

    Thanks to Patrick Hofman's answer, I modified the code and ended up with this :

    $(document).ready(function(){  
    
      function readMultipleFiles(evt) {
        //Retrieve all the files from the FileList object
        var files = evt.target.files; 
    
        if (files) {
            for (var i=0, f; f=files[i]; i++) {
                  var r = new FileReader();
                r.onload = (function(f) {
                    return function(e) {
                        var contents = e.target.result;
                        $('body').append('

    ' + f.name + '

    '); }; })(f); r.readAsText(f); } } else { alert("Failed to load files"); } } document.getElementById('fileinput').addEventListener('change', readMultipleFiles, false); });

提交回复
热议问题