+ 1

Set the number of file allowed to be uploaded

How to set limit on the number of file to upload( let say a max of 3 files)

6th Jan 2019, 2:57 PM
Brown
Brown - avatar
8 odpowiedzi
+ 2
From: https://stackoverflow.com/questions/18201811/how-can-restrict-user-to-upload-max-10-files-at-once <input id="files" type="file" name="files[]" multiple="multiple" onchange="checkFiles(this.files)"> function checkFiles(files) { if(files.length>10) { alert("length exceeded"); files.slice(0,10); return false; } }
6th Jan 2019, 6:06 PM
Calviղ
Calviղ - avatar
+ 2
Set a flag and a counter For each action, increase counter by one When counter reaches three, set the flag as true Enclose the action in a checking and execute only when the flag is false.
6th Jan 2019, 3:48 PM
Gordon
Gordon - avatar
+ 2
JS var flag = false; var counter = 0; if (!flag) { ...do something... if(++counter==3){flag=true;} }
6th Jan 2019, 4:02 PM
Gordon
Gordon - avatar
+ 2
Sorry I don't know about form. I hope someone else can help you.
6th Jan 2019, 5:42 PM
Gordon
Gordon - avatar
0
ok
6th Jan 2019, 3:49 PM
Brown
Brown - avatar
0
please can you write some code.appreciate
6th Jan 2019, 3:51 PM
Brown
Brown - avatar
0
<form> <input type=“file” name=“file[]” multiple> </form> please add the js handler to the form
6th Jan 2019, 4:06 PM
Brown
Brown - avatar
0
thanks
6th Jan 2019, 6:19 PM
Brown
Brown - avatar