javascript - How to make image upload directly while choosing image rather than pressing upload button in JQuery -
how make script make upload file rather pressing upload button in below script
detail :
in below <input type="file" id="pimage" name="image" class="upload-img" style="opacity:0">
display image uploaded , <input name="image" type="file"/>
choose file. , <button>upload</button>
upload image.
and in <input type="file" id="pimage" name="image" class="upload-img" style="opacity:0">
choose file, don't want upload image every time after clicking on upload button
how can make image upload while choosing file itself
html :
<div id="image" class="upload-img-span"></div> <input type="file" id="pimage" name="image" class="upload-img" style="opacity:0"> <span class="upload-txt-span">upload img</span> </div> </td> </tr> <td colspan="4" align="left"> <input name="image" type="file"/> <button>upload</button>
script :
<script> $("form#data").submit(function(){ var formdata = new formdata($(this)[0]); $.ajax({ url: 'globalimageupload', type: 'post', data: formdata, async: false, success: function (data) { $('#image').html(data); console.log(data) }, cache: false, contenttype: false, processdata: false }); return false; }); </script>
i not sure want take @ .trigger() docs here. can trigger other event, click of upload in case.hope helps
Comments
Post a Comment