I currently have the below for uploading images, but I also want to add a restriction that prevents users from uploading any file less than 50px
in height
. Is this possible?
file_field "form", "image", accept: 'image/png,image/gif,image/jpeg'
I currently have the below for uploading images, but I also want to add a restriction that prevents users from uploading any file less than 50px
in height
. Is this possible?
file_field "form", "image", accept: 'image/png,image/gif,image/jpeg'
Yes it's possible, but you need some javascript to do it on the client side, here is am example. Change that html input to the rails helper.
html
the js code:
In this example image was uploaded and the you able to get the width and the height.
JSFIDDLE
Read how the works with JS in Rails
7 Must-Reads about JavaScript with Ruby on Rails
Try this one, Maybe this will help you: Reference
This will work for you if you use
MiniMagick
.