I'm using IS_LENGTH in my model to validate file size of uploaded image:
IS_LENGTH(2097152, 1, error_message='Max image size: 2MB')
However, the size is being checked after the file's been uploaded, which is not very user friendly when it comes to files larger than 2MB. How can I first validate the file size and then - if it's lower than 2MB - proceed with upload? Can it be done with Python or do I need JS for this?