Forum Discussion
SiniWickramasin
6 years agoQrew Cadet
Hi Dan,
I tried this method and it worked great for one file attachment field. However my requirement is a bit different. I have a form with multiple fields with file attachments. Example Photo1, Photo2, Photo3 etc. Ideally when the users click on either one of the "browse" buttons to locate image file and if the file is more than 1Mb, I would like to stop them from uploading. I'm very new to JS so having troubles applying this method. Any advice would be greatly appreciated!!!
Many thanks in advance!
I tried this method and it worked great for one file attachment field. However my requirement is a bit different. I have a form with multiple fields with file attachments. Example Photo1, Photo2, Photo3 etc. Ideally when the users click on either one of the "browse" buttons to locate image file and if the file is more than 1Mb, I would like to stop them from uploading. I'm very new to JS so having troubles applying this method. Any advice would be greatly appreciated!!!
Many thanks in advance!
AustinK
6 years agoQrew Commander
The part that matters the most is the first line inside the bit that says "#_fid_6" you would just change that to be whatever field you wanted but it must go by the field id(FID.) You can have multiple selectors in jquery and can do it this way. This will watch all 3 fields for changes and alert if the file size is not 1000... bytes? Whatever it is.
You are going to have to fix the indentation. QuickBase has absolutely ruined this and it's actually very difficult to get posted in one code box.
$("#_fid_6,#_fid_7,#_fid_8").on("change", function(e) { var maxSize = 1000; var data = e.originalEvent.target.files[0]; if (data.size > maxSize) { alert('Your file size is ${data.size}. Please select a smaller file.'); this.value = ""; } });
You are going to have to fix the indentation. QuickBase has absolutely ruined this and it's actually very difficult to get posted in one code box.