The jQuery plugin imgPreviewQs implements image preview and jqueryimgpreviewqs
Preview uploaded images, including Internet Explorer 6, Internet Explorer 7, Internet Explorer 8, Internet Explorer 9, Internet Explorer 10, and Internet Explorer 11. Firefox and Chrome are not tested, but they are supported in later versions.
ImgPreviewQs. js
/*! Dependent on jQuery 1.5.2 (c) 2016 license: http://www.opensource.org/licenses/mit-license.php#/ (function ($) {$. fn. imgPreviewQs = function (options) {function isIE (ver) {var B = document. createElement ('B') B. innerHTML = '<! -- [If IE '+ ver +']> <I> </I> <! [Endif] --> 'Return B. getElementsByTagName ('I '). length = 1;} options = $. extend ({}, $. fn. imgPreviewQs. defaults, options); var $ this = $ (this); $ this. change (function () {var regex = /(. *)\. (jpg | jpeg | gif | bmp | png) $/; var val = $ this. val (); if (! Regex. test (val) {alert ("select image"); return false;} if (browserQs. isIE (8) {HanderIE789 ($ this);} else if (window. fileReader) {HanderFileReader ($ this);} else if (browserQs. isIE (9) {HanderIE789 ($ this);} else if (browserQs. isIE (6) {HanderOther ($ this);} else if (browserQs. isIE (7) {HanderIE789 ($ this);} else {$ ("#" javasoptions.destid#.html ("preview images not supported by browsers ");}}); function HanderFileReader ($ this) {var oPreviewI Mg = null, oFReader = new window. FileReader (), rFilter =/^ (?: Image \/bmp | image \/cis \-cod | image \/gif | image \/ief | image \/jpeg | image \ /pipeg | image \/png | image \/svg \ + xml | image \/tiff | image \/x \-cmu \-raster | image \/x \-cmx | image \/x \-icon | image \/x \-portable \-anymap | image \/x \-portable \-bitmap | image \/x \-portable \-graymap | image \/x \-portable \-pixmap | image \/x \-rgb | image \/x \-xbitmap | image \/x \-xpixmap | image \/x \-xwindowdump) $/I; oFReader. onload = function (OFREvent) {$ ("#" incluoptions.destid).html ("
Articles you may be interested in:
- Jquery-based code for Image Upload and image size verification and image Preview
- JQuery enables local preview and upload of images