php - How to get the file of a balise img in the controller -


i work onn symfony , have file selected in order use vich uploader bundle , save file in daabase have input type file , user choose picture(s) , show them in img balise have submit file choosen controller can have method load file of img balise there html

<input type='file' id="imginp" name="imageselect" multiple/>  <div id="images">          <img id="img1" src="#" alt="your image" width="200" height="200"/>  <img id="img2" src="#" alt="your image" width="20" height="20" />  </div> 

there method used in order show pictures

 $(window).load(function(){         var position = 0 ;         function readurl(input) {              if (input.files && input.files[0]) {                 var reader = new filereader();                 reader.onload = function (e) {                     position=position+1;                     $('#img'+position).attr('src', e.target.result);                 }                 //if(document.getelementbyid(blah).)                  reader.readasdataurl(input.files[0]);             }                }           $("#imginp").change(function(){             readurl(this);         });     }); 

in controller if use $file1 = $request->files->get('imageselect'); have last selected pic , $file2 = $request->files->get("img2"); returns null


Comments