php - Handling uploaded files Javascript/jQuery -


i trying build website has uploading multiple files. php files' type (images destination folder x, audio destination folder y, video destination folder z , docs docs) upload them specific, type, folder. works pretty , decided go further creating more interactive ui. idea to, whenever user selects 10 files example, these 10 files , show user going upload. mean these 10 little thumbnails control buttons delete.javascript seemed way i've searched google , stackoverflow , far got code

$('#inputfile').change( function () {     var s = [];     (var = 0; < $(this).get(0).files.length; i++){         s.push($(this).get(0).files[i].name);         readurl(this);     } });  function readurl(input){     if(input.files && input.files[0]){         var reader = new filereader();             reader.onload = function (e){                 var img = $('<img>',{                     width: '200px',                     src: e.target.result                 });                 img.appendto($('.images'));             }         reader.readasdataurl(input.files[0]);     } } 

there no explain here. #inputfile input's id. don't understand code does. if select 10 images. create 10 thumbnails 1st image selected. ends having 10 same thumbnails. tried on own fix couldn't. know input's handler function readurl called , input whole element not value of input#inputfile , confused me. long kinda works it's ok. know problem place call readurl , parameter use. whatever tried showed nothing @ all. if there other way achieve goal using php or else. please let me know

try that

$('#inputfile').change( function () {     var s = [];     (var = 0; < $(this).get(0).files.length; i++){         var file = $(this).get(0).files[i];         s.push(file.name);         readurl(file);     } });  function readurl(file){     if(file){         var reader = new filereader();             reader.onload = function (e){                 var img = $('<img>',{                     width: '200px',                     src: e.target.result                 });                 img.appendto($('.images'));             }         reader.readasdataurl(file);     } } 

Comments

Popular posts from this blog

angular - Ionic slides - dynamically add slides before and after -

minify - Minimizing css files -

Add a dynamic header in angular 2 http provider -