javascript - jQuery image preview on change -


I am using the function below to display an image preview after selecting the file.
If the file extension eq file type should display it image preview, but it is not. What am I doing wrong?

  var previewImage = function (input, block) {var fileTypes = ['jpg', 'JPEG', 'PNG']; Var extension = input.files [0] .name.split ('.'). Pop (). ToLowerCase (); / * Before extensia * / var hasiivet = filetap.indexoff (extension) & gt; -1; / * Verification extensia * / if (hashut) {var reader = new FileReader (); Reader.loads = function (e) {block.attr ('src', e.target.result); }; } And {warnings ('accepting this fisheries!'); }}; $ S (document) .on ('change', '#image', function () {previewImage (this, $ s ('. ImagePreview'));};  

And here's my input.

  & lt; Div class = "control-group form-group" & gt; & Lt; Label = "picture" & gt; Imigini & lt; / Label & gt; & Lt; Div id = "image preview" & gt; & Lt; Img src = "/ admin / mmadmin / template / assets / img-upload-150_150.png" square = "image preview thumbnail" style = "max-width: 150px; max-height: 150px;" / & Gt; & Lt; / Div & gt; & Lt; Input type = "file" name = "imageFile" id = "picture" /> & Lt; / Div & gt;  

Task Bela:

Ok there are some issues: First of all, which is after $ jQuery.

  $ (document) .on ('change', '#image', function () {previewImage (this, $ ('. ImagePreview'));};  

Then, you forgot to ask the reader to read the data:

  reader.readAsDataURL (input.files [0]);  

Comments

Popular posts from this blog

winforms - C# Form - Property Change -

java - Messages from .properties file do not display UTF-8 characters -

javascript - amcharts makechart not working -