Join us and the lead editor of IRL, Mozilla's multi-award-winning podcast, for a behind-the-scenes look at the pod and to contribute your ideas for the next season, themed: "AI and ME." Mark your calendar and join our Community Call on Wednesday, Aug 7, 17:00–17:45 UTC. See you there!

Search Support

Avoid support scams. We will never ask you to call or text a phone number or share personal information. Please report suspicious activity using the “Report Abuse” option.

Learn More

Wannan tattunawa ta zama daɗaɗɗiya. Yi sabuwar tambaya idan ka na bukatar taimako.

Javascript can not display jpg files of 4 MB or more. Is there any limitation?

  • 1 amsa
  • 1 yana da wannan matsala
  • 1 view
  • Amsa ta ƙarshe daga TyDraniu

more options

html

       <input type='file' id="imgInp" />
       your image


js

   $("#imgInp").change(function() {

readURL(this);

   });


function readURL(input) {

   if (input.files && input.files[0]) {
       let reader = new FileReader();
 
       reader.onload = function(e) {
           $('#blah').attr('src', e.target.result);
       };
 
       reader.readAsDataURL(input.files[0]);
   }

}

Javascript can not display jpg files of 4 MB or more. Is there any limitation?

html <input type='file' id="imgInp" /> <img id="blah" src="#" alt="your image" /> js $("#imgInp").change(function() { readURL(this); }); function readURL(input) { if (input.files && input.files[0]) { let reader = new FileReader(); reader.onload = function(e) { $('#blah').attr('src', e.target.result); }; reader.readAsDataURL(input.files[0]); } } Javascript can not display jpg files of 4 MB or more. Is there any limitation?

All Replies (1)

more options

The example on this page works for me for 5MB jpg. I don't think there's any limitation of such a small size.