Added file size check

pull/3/head
Davide Bongiovanni 6 years ago
parent 257a8d9754
commit 501491ac9a

@ -73,12 +73,17 @@ function save(partID) {
}
var data = new FormData();
if (datasheet.length == 1)
if (datasheet.length == 1) {
if(! datasheet[0]['name'].match(/^[\w\-]+\.pdf$/g)) {
alert('Invalid filename. Please match /^[\w\-]+\.pdf$/g');
return;
}
if (datasheet[0]['size'] > 20 * 1000000) {
alert('File too large. Must be < 20MB.');
return;
}
data.append('datasheet-file', datasheet[0]);
}
data.append('partno', partno_v);
data.append('location_id', location_id_v)
data.append('description', description_v);

Loading…
Cancel
Save