How to check width and height before insert image by using [Package CollectionFS]

36 Views Asked by At

Need help for this.

I have tried upload some image, i would like to check that width and height before insert to db.I stuck when try to check while at lib collection.

thx in advanced.

1

There are 1 best solutions below

0
rajesh On

You should be able to do it in server side. If you want to do it in client side you can try like this. But not sure about browser support.

var _URL = window.URL || window.webkitURL; 
$("#file").change(function (e) { 
  var file, img; 
  if ((file = this.files[0])) {
   img = new Image();
   img.onload = function () { 
      alert(this.width + " " + this.height);
   }; 
   img.src = _URL.createObjectURL(file);
  }
 });

Note: I have taken plane js approach. Not using package collection.