Mozilla Destek’te Ara

Destek dolandırıcılığından kaçının. Mozilla sizden asla bir telefon numarasını aramanızı, mesaj göndermenizi veya kişisel bilgilerinizi paylaşmanızı istemez. Şüpheli durumları “Kötüye kullanım bildir” seçeneğini kullanarak bildirebilirsiniz.

Learn More

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

  • 1 yanıt
  • 1 kişi bu sorunu yaşıyor
  • 1 gösterim
  • Son yanıtı yazan: 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?

Tüm Yanıtlar (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.