JQuery/PHP multiple files one at a time with only one input field -


i search through net didn't find things on problem. hope here can help! write in title want upload mutliple files, 1 @ time, 1 input. tried using jquery can see below, doesn't work! can help, please?

    <!doctype html>     <html>     <script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>     <head>     <script>     $(document).ready(function() {         $(document).on('change', '.file',function(){             $('<input type="file" name="file[]" class="file" size="60" />').appendto($("#divajout"));             $("div input:first-child").remove();               return false;         });     });     </script>      <title>test input file unique pour plusieurs fichiers</title>     </head>      <body>     <form action="" method="post" enctype='multipart/form-data'>     <div id="divajout">         <input type="file" name="file[]" class="file" id='file' size="60" />         </div>           <input name="submit" type="submit">     </form>     <?php       if(isset($_post['submit'])){echo'<pre>'; print_r($_files);echo'<pre>';} ?>     </body>     </html> 

you can clone input file incrementing name attribute, file[0], file[1], file[2], etc.

function readurl(input) {                 var index = ($(input).data('index'));                 if (input.files && input.files[0]) {                     var reader = new filereader();                     reader.onload = function (e) {                         $(input).parent().children('.newimage')                             .attr('src', e.target.result)                             .height(120);                     };                     reader.readasdataurl(input.files[0]);                      $('.addph').show();                     $('.addph').last().clone().insertbefore($('#addphoto')).hide();                     ++index;                     $('.addph').last().children('.photo_new').data('index', index).attr('name', 'photo_new['+index+']');                 } }  $(document).ready(function () {     $('#addphoto').click(function () {         $('.photo_new').last().click();     });  }); 

see example: https://jsfiddle.net/w0cd3ls4/3/


Comments

Popular posts from this blog

java - activate/deactivate sonar maven plugin by profile? -

python - TypeError: can only concatenate tuple (not "float") to tuple -

java - What is the difference between String. and String.this. ? -