javascript - Laravel,Ajax,Jquery Plugin image upload,preview, convert to thumbnails and display -
enter image description herepreview uploaded images after upload.and show image on form.want achieve of jquery image upload laravel framework. appreciated.
@simon have implemented ur code.its working,but 1 image shown in view , want show 3 images,which selected.plz helpenter image description here
if using standard file input type , using moderish browser etc try following.
$('#addimage').on('change', function(evt) { var selectedimage = evt.currenttarget.files[0]; var imagewrapper = document.queryselector('.image-wrapper'); var theimage = document.createelement('img'); imagewrapper.innerhtml = ''; var regex = /^([a-za-z0-9\s_\\.\-:])+(.jpg|.jpeg|.gif|.png|.bmp)$/; if (regex.test(selectedimage.name.tolowercase())) { if (typeof(filereader) != 'undefined') { var reader = new filereader(); reader.onload = function(e) { theimage.id = 'new-selected-image'; theimage.src = e.target.result; imagewrapper.appendchild(theimage); } // reader.readasdataurl(selectedimage); } else { //-- let user knwo cannot peform browser out of date console.log('browser support issue'); } } else { //-- no image let user knwo need one... $(this).prop('value', null); console.log('please select , image file'); } });
.wrapper { padding: 25px; } .image-wrapper { padding: 5px; border: 1px #ddd solid; height auto; width: 200px; } .image-wrapper img { max-width: 200px; }
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <div class="wrapper"> <input type="file" id="addimage" /> </div> <div class="image-wrapper"> </div>
also viewable on codepen exmaple
Comments
Post a Comment