Getting image size before uploading

i want to store file in folder based on the size is there any way to get size of the file before uploading

please help me

max_file_size = frappe.db.get_value(‘Web Form’, dict(title='Pre-Registration Corporate '), ‘max_attachment_size’)

if max_file_size > selected_file_size:
     print 'some messge"

this is what i want to do