Sök i support

Akta dig för supportbedrägerier: Vi kommer aldrig att be dig att ringa eller skicka ett sms till ett telefonnummer eller dela personlig information. Rapportera misstänkt aktivitet med alternativet "Rapportera missbruk".

Learn More

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

  • 1 svar
  • 1 har detta problem
  • 1 visning
  • Senaste svar av 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?

Alla svar (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.