javascript - jquery multiple files upload using single file element -


i want upload maximum 2 files using single file input. referred site http://hungred.com/how-to/multiple-upload-single-upload-file-jquery/. there problem delete button. me delete 'click' event triggered twice. is, if delete file, both 2 files getting removed.

also need unique ids 2 file inputs. can 1 me ?

here code:

jquery(document).ready(function($){ var max = 2; var replaceme = function(){ var obj = $(this); $('#previewrow').css('display',''); if($("input[type='file']").length > max) {                obj.val("");         return false; } $(obj).css({'position':'absolute','left':'-9999px','display':'none'}).parent().prepend('<input type="file" class="fileinput hidden" name="'+obj.attr('name')+'"/>'); $('#preview').append('<div>'+obj.val()+'<a class="clearitem" href="javascript:void(0)">x</a><div>'); $("input[type='file']").change(replaceme); $(".clearitem").click(function(){         $(this).parent().remove();         $(obj).remove();         return false; //safari fixes });  } $("input[type='file']").change(replaceme); }); 

there many jquery plugins.uploadify 1 of best have ever found. can see demo also. there extensive documentation customize per requirements.


Comments

Popular posts from this blog

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

html - How to style widget with post count different than without post count -

url rewriting - How to redirect a http POST with urlrewritefilter -