How to limit the upload of an image by its size in pixels?

1

I'm doing an application with VueJS and I have an image upload input and I want to set a size limit of image to upload, not in KB or MB, but rather based on its pixels ie only allow upload if the image respects the pixel limit.

Eg 320x280

If the image is larger than this issue a warning that can not be larger than the stipulated size.

Here I have the function in JS that receives the image

carregarFoto (e) {
  var arquivo = e.target.files
  if (!arquivo[0]) {
    return
  }
  var data = new FormData()
  data.append('media', arquivo[0])
  var reader = new FileReader()
  reader.onload = (e) => {
    this.foto = e.target.result
    console.log(this.camposForm.foto)
  }
  reader.readAsDataURL(arquivo[0])
},

Here is the input:

<input @change="carregarFoto" type="file" name="photo" accept="image/*">

I've tried using this link , but it did not work and I'm still looking for answers, if anyone can help me I appreciate

    
asked by anonymous 04.10.2017 / 20:26

0 answers