jquery file upload restricting number of files
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;
I am using jquery file upload to upload the files to the server . I want to restrict the user to upload maximum 6 files . I search the wiki jquery file upload but didnt find the parameter for it . Is there any way that i can restrict the user on number of uplaods
jquery jquery-file-upload
add a comment |
I am using jquery file upload to upload the files to the server . I want to restrict the user to upload maximum 6 files . I search the wiki jquery file upload but didnt find the parameter for it . Is there any way that i can restrict the user on number of uplaods
jquery jquery-file-upload
which jquery plugin you are using? generally inside callback function it will hold those files in some sort of json array whose size you can put in if() clause
– duckduckgo
Apr 15 '13 at 9:07
A why not working version: stackoverflow.com/questions/21347805/…
– Ciro Santilli 新疆改造中心996ICU六四事件
Nov 8 '14 at 9:33
add a comment |
I am using jquery file upload to upload the files to the server . I want to restrict the user to upload maximum 6 files . I search the wiki jquery file upload but didnt find the parameter for it . Is there any way that i can restrict the user on number of uplaods
jquery jquery-file-upload
I am using jquery file upload to upload the files to the server . I want to restrict the user to upload maximum 6 files . I search the wiki jquery file upload but didnt find the parameter for it . Is there any way that i can restrict the user on number of uplaods
jquery jquery-file-upload
jquery jquery-file-upload
asked Apr 15 '13 at 8:54
UahmedUahmed
1,08142035
1,08142035
which jquery plugin you are using? generally inside callback function it will hold those files in some sort of json array whose size you can put in if() clause
– duckduckgo
Apr 15 '13 at 9:07
A why not working version: stackoverflow.com/questions/21347805/…
– Ciro Santilli 新疆改造中心996ICU六四事件
Nov 8 '14 at 9:33
add a comment |
which jquery plugin you are using? generally inside callback function it will hold those files in some sort of json array whose size you can put in if() clause
– duckduckgo
Apr 15 '13 at 9:07
A why not working version: stackoverflow.com/questions/21347805/…
– Ciro Santilli 新疆改造中心996ICU六四事件
Nov 8 '14 at 9:33
which jquery plugin you are using? generally inside callback function it will hold those files in some sort of json array whose size you can put in if() clause
– duckduckgo
Apr 15 '13 at 9:07
which jquery plugin you are using? generally inside callback function it will hold those files in some sort of json array whose size you can put in if() clause
– duckduckgo
Apr 15 '13 at 9:07
A why not working version: stackoverflow.com/questions/21347805/…
– Ciro Santilli 新疆改造中心996ICU六四事件
Nov 8 '14 at 9:33
A why not working version: stackoverflow.com/questions/21347805/…
– Ciro Santilli 新疆改造中心996ICU六四事件
Nov 8 '14 at 9:33
add a comment |
5 Answers
5
active
oldest
votes
Use maxNumberOfFiles
here is documentation :
$('#fileuploadbasic').fileupload(
maxNumberOfFiles: 6
);
1
This does not work in my case. I can select more than 6 files and it also uploads all selected files.
– basZero
May 9 '17 at 13:50
I found that sometimes the browser caches the .js file. Try refreshing the actual .js page and see if the changes take effect then.
– BSUK
Nov 27 '17 at 14:23
add a comment |
maxNumberOfFiles was not working for me so i did the following
$('#fileuploadbasic').fileupload(
change : function (e, data)
if(data.files.length>=5)
alert("Max 5 files are allowed")
return false;
,
maxFileSize: 20000000,
acceptFileTypes: /(.);
3
Awesome, exactly what I needed.
– Cesar Bielich
Jun 2 '16 at 19:19
3
This is also not working for me.
– rida mukhtar
Dec 23 '16 at 13:33
3
I can't edit the answer for some reason, but if you replace the "change" handler by "submit", it will work. That did the trick for me and "change" wasn't working either :)
– NaturalBornCamper
Mar 16 '17 at 9:29
@naturalBornCamper above code is for the time when we select file. it check the file before submitting.
– Muhammad Tahir
Jun 4 '17 at 19:08
add a comment |
You can limit the uploading files by the "Uploadhandler.php" file .change the "max_number_of_files" option. works for me. But it only validates when you upload the file.
This is valid. A lot of the settings are available client side (via js) and server side (via PHP). I found it useful to duplicate on both, so that the user gets client feedback before the file has been uploaded, but a more secure level of validation takes place on the server also.
– BSUK
Nov 27 '17 at 14:25
Just remember to have some place to show this limit. In my case 100 uploads worked and the others failed, with no error message, just "An error ocurred".
– Marcelo Agimóvel
Mar 19 '18 at 2:41
add a comment |
You can try:
$('#fileuploadbasic').fileupload(
//.....
paramName: 'your_input_name',
add : function (e, data)
if(data.paramName != undefined) data.submit();
);
add a comment |
If you are using the "Krajee" fileupload, then you will have to use
$('#fileuploadbasic').fileinput(
maxFileCount: 6
);
If set to 0, it means size allowed is unlimited. Defaults to 0.
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f16011200%2fjquery-file-upload-restricting-number-of-files%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
5 Answers
5
active
oldest
votes
5 Answers
5
active
oldest
votes
active
oldest
votes
active
oldest
votes
Use maxNumberOfFiles
here is documentation :
$('#fileuploadbasic').fileupload(
maxNumberOfFiles: 6
);
1
This does not work in my case. I can select more than 6 files and it also uploads all selected files.
– basZero
May 9 '17 at 13:50
I found that sometimes the browser caches the .js file. Try refreshing the actual .js page and see if the changes take effect then.
– BSUK
Nov 27 '17 at 14:23
add a comment |
Use maxNumberOfFiles
here is documentation :
$('#fileuploadbasic').fileupload(
maxNumberOfFiles: 6
);
1
This does not work in my case. I can select more than 6 files and it also uploads all selected files.
– basZero
May 9 '17 at 13:50
I found that sometimes the browser caches the .js file. Try refreshing the actual .js page and see if the changes take effect then.
– BSUK
Nov 27 '17 at 14:23
add a comment |
Use maxNumberOfFiles
here is documentation :
$('#fileuploadbasic').fileupload(
maxNumberOfFiles: 6
);
Use maxNumberOfFiles
here is documentation :
$('#fileuploadbasic').fileupload(
maxNumberOfFiles: 6
);
answered Apr 15 '13 at 9:18
Mohamed AliMohamed Ali
1,4661116
1,4661116
1
This does not work in my case. I can select more than 6 files and it also uploads all selected files.
– basZero
May 9 '17 at 13:50
I found that sometimes the browser caches the .js file. Try refreshing the actual .js page and see if the changes take effect then.
– BSUK
Nov 27 '17 at 14:23
add a comment |
1
This does not work in my case. I can select more than 6 files and it also uploads all selected files.
– basZero
May 9 '17 at 13:50
I found that sometimes the browser caches the .js file. Try refreshing the actual .js page and see if the changes take effect then.
– BSUK
Nov 27 '17 at 14:23
1
1
This does not work in my case. I can select more than 6 files and it also uploads all selected files.
– basZero
May 9 '17 at 13:50
This does not work in my case. I can select more than 6 files and it also uploads all selected files.
– basZero
May 9 '17 at 13:50
I found that sometimes the browser caches the .js file. Try refreshing the actual .js page and see if the changes take effect then.
– BSUK
Nov 27 '17 at 14:23
I found that sometimes the browser caches the .js file. Try refreshing the actual .js page and see if the changes take effect then.
– BSUK
Nov 27 '17 at 14:23
add a comment |
maxNumberOfFiles was not working for me so i did the following
$('#fileuploadbasic').fileupload(
change : function (e, data)
if(data.files.length>=5)
alert("Max 5 files are allowed")
return false;
,
maxFileSize: 20000000,
acceptFileTypes: /(.);
3
Awesome, exactly what I needed.
– Cesar Bielich
Jun 2 '16 at 19:19
3
This is also not working for me.
– rida mukhtar
Dec 23 '16 at 13:33
3
I can't edit the answer for some reason, but if you replace the "change" handler by "submit", it will work. That did the trick for me and "change" wasn't working either :)
– NaturalBornCamper
Mar 16 '17 at 9:29
@naturalBornCamper above code is for the time when we select file. it check the file before submitting.
– Muhammad Tahir
Jun 4 '17 at 19:08
add a comment |
maxNumberOfFiles was not working for me so i did the following
$('#fileuploadbasic').fileupload(
change : function (e, data)
if(data.files.length>=5)
alert("Max 5 files are allowed")
return false;
,
maxFileSize: 20000000,
acceptFileTypes: /(.);
3
Awesome, exactly what I needed.
– Cesar Bielich
Jun 2 '16 at 19:19
3
This is also not working for me.
– rida mukhtar
Dec 23 '16 at 13:33
3
I can't edit the answer for some reason, but if you replace the "change" handler by "submit", it will work. That did the trick for me and "change" wasn't working either :)
– NaturalBornCamper
Mar 16 '17 at 9:29
@naturalBornCamper above code is for the time when we select file. it check the file before submitting.
– Muhammad Tahir
Jun 4 '17 at 19:08
add a comment |
maxNumberOfFiles was not working for me so i did the following
$('#fileuploadbasic').fileupload(
change : function (e, data)
if(data.files.length>=5)
alert("Max 5 files are allowed")
return false;
,
maxFileSize: 20000000,
acceptFileTypes: /(.);
maxNumberOfFiles was not working for me so i did the following
$('#fileuploadbasic').fileupload(
change : function (e, data)
if(data.files.length>=5)
alert("Max 5 files are allowed")
return false;
,
maxFileSize: 20000000,
acceptFileTypes: /(.);
answered May 14 '15 at 11:52
Muhammad TahirMuhammad Tahir
1,2821619
1,2821619
3
Awesome, exactly what I needed.
– Cesar Bielich
Jun 2 '16 at 19:19
3
This is also not working for me.
– rida mukhtar
Dec 23 '16 at 13:33
3
I can't edit the answer for some reason, but if you replace the "change" handler by "submit", it will work. That did the trick for me and "change" wasn't working either :)
– NaturalBornCamper
Mar 16 '17 at 9:29
@naturalBornCamper above code is for the time when we select file. it check the file before submitting.
– Muhammad Tahir
Jun 4 '17 at 19:08
add a comment |
3
Awesome, exactly what I needed.
– Cesar Bielich
Jun 2 '16 at 19:19
3
This is also not working for me.
– rida mukhtar
Dec 23 '16 at 13:33
3
I can't edit the answer for some reason, but if you replace the "change" handler by "submit", it will work. That did the trick for me and "change" wasn't working either :)
– NaturalBornCamper
Mar 16 '17 at 9:29
@naturalBornCamper above code is for the time when we select file. it check the file before submitting.
– Muhammad Tahir
Jun 4 '17 at 19:08
3
3
Awesome, exactly what I needed.
– Cesar Bielich
Jun 2 '16 at 19:19
Awesome, exactly what I needed.
– Cesar Bielich
Jun 2 '16 at 19:19
3
3
This is also not working for me.
– rida mukhtar
Dec 23 '16 at 13:33
This is also not working for me.
– rida mukhtar
Dec 23 '16 at 13:33
3
3
I can't edit the answer for some reason, but if you replace the "change" handler by "submit", it will work. That did the trick for me and "change" wasn't working either :)
– NaturalBornCamper
Mar 16 '17 at 9:29
I can't edit the answer for some reason, but if you replace the "change" handler by "submit", it will work. That did the trick for me and "change" wasn't working either :)
– NaturalBornCamper
Mar 16 '17 at 9:29
@naturalBornCamper above code is for the time when we select file. it check the file before submitting.
– Muhammad Tahir
Jun 4 '17 at 19:08
@naturalBornCamper above code is for the time when we select file. it check the file before submitting.
– Muhammad Tahir
Jun 4 '17 at 19:08
add a comment |
You can limit the uploading files by the "Uploadhandler.php" file .change the "max_number_of_files" option. works for me. But it only validates when you upload the file.
This is valid. A lot of the settings are available client side (via js) and server side (via PHP). I found it useful to duplicate on both, so that the user gets client feedback before the file has been uploaded, but a more secure level of validation takes place on the server also.
– BSUK
Nov 27 '17 at 14:25
Just remember to have some place to show this limit. In my case 100 uploads worked and the others failed, with no error message, just "An error ocurred".
– Marcelo Agimóvel
Mar 19 '18 at 2:41
add a comment |
You can limit the uploading files by the "Uploadhandler.php" file .change the "max_number_of_files" option. works for me. But it only validates when you upload the file.
This is valid. A lot of the settings are available client side (via js) and server side (via PHP). I found it useful to duplicate on both, so that the user gets client feedback before the file has been uploaded, but a more secure level of validation takes place on the server also.
– BSUK
Nov 27 '17 at 14:25
Just remember to have some place to show this limit. In my case 100 uploads worked and the others failed, with no error message, just "An error ocurred".
– Marcelo Agimóvel
Mar 19 '18 at 2:41
add a comment |
You can limit the uploading files by the "Uploadhandler.php" file .change the "max_number_of_files" option. works for me. But it only validates when you upload the file.
You can limit the uploading files by the "Uploadhandler.php" file .change the "max_number_of_files" option. works for me. But it only validates when you upload the file.
answered Jul 1 '16 at 10:54
HemanthaHemantha
19317
19317
This is valid. A lot of the settings are available client side (via js) and server side (via PHP). I found it useful to duplicate on both, so that the user gets client feedback before the file has been uploaded, but a more secure level of validation takes place on the server also.
– BSUK
Nov 27 '17 at 14:25
Just remember to have some place to show this limit. In my case 100 uploads worked and the others failed, with no error message, just "An error ocurred".
– Marcelo Agimóvel
Mar 19 '18 at 2:41
add a comment |
This is valid. A lot of the settings are available client side (via js) and server side (via PHP). I found it useful to duplicate on both, so that the user gets client feedback before the file has been uploaded, but a more secure level of validation takes place on the server also.
– BSUK
Nov 27 '17 at 14:25
Just remember to have some place to show this limit. In my case 100 uploads worked and the others failed, with no error message, just "An error ocurred".
– Marcelo Agimóvel
Mar 19 '18 at 2:41
This is valid. A lot of the settings are available client side (via js) and server side (via PHP). I found it useful to duplicate on both, so that the user gets client feedback before the file has been uploaded, but a more secure level of validation takes place on the server also.
– BSUK
Nov 27 '17 at 14:25
This is valid. A lot of the settings are available client side (via js) and server side (via PHP). I found it useful to duplicate on both, so that the user gets client feedback before the file has been uploaded, but a more secure level of validation takes place on the server also.
– BSUK
Nov 27 '17 at 14:25
Just remember to have some place to show this limit. In my case 100 uploads worked and the others failed, with no error message, just "An error ocurred".
– Marcelo Agimóvel
Mar 19 '18 at 2:41
Just remember to have some place to show this limit. In my case 100 uploads worked and the others failed, with no error message, just "An error ocurred".
– Marcelo Agimóvel
Mar 19 '18 at 2:41
add a comment |
You can try:
$('#fileuploadbasic').fileupload(
//.....
paramName: 'your_input_name',
add : function (e, data)
if(data.paramName != undefined) data.submit();
);
add a comment |
You can try:
$('#fileuploadbasic').fileupload(
//.....
paramName: 'your_input_name',
add : function (e, data)
if(data.paramName != undefined) data.submit();
);
add a comment |
You can try:
$('#fileuploadbasic').fileupload(
//.....
paramName: 'your_input_name',
add : function (e, data)
if(data.paramName != undefined) data.submit();
);
You can try:
$('#fileuploadbasic').fileupload(
//.....
paramName: 'your_input_name',
add : function (e, data)
if(data.paramName != undefined) data.submit();
);
answered Jul 14 '16 at 8:58
ArtipixelArtipixel
823816
823816
add a comment |
add a comment |
If you are using the "Krajee" fileupload, then you will have to use
$('#fileuploadbasic').fileinput(
maxFileCount: 6
);
If set to 0, it means size allowed is unlimited. Defaults to 0.
add a comment |
If you are using the "Krajee" fileupload, then you will have to use
$('#fileuploadbasic').fileinput(
maxFileCount: 6
);
If set to 0, it means size allowed is unlimited. Defaults to 0.
add a comment |
If you are using the "Krajee" fileupload, then you will have to use
$('#fileuploadbasic').fileinput(
maxFileCount: 6
);
If set to 0, it means size allowed is unlimited. Defaults to 0.
If you are using the "Krajee" fileupload, then you will have to use
$('#fileuploadbasic').fileinput(
maxFileCount: 6
);
If set to 0, it means size allowed is unlimited. Defaults to 0.
answered Dec 23 '17 at 13:10
TheCodeLordTheCodeLord
429511
429511
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f16011200%2fjquery-file-upload-restricting-number-of-files%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
which jquery plugin you are using? generally inside callback function it will hold those files in some sort of json array whose size you can put in if() clause
– duckduckgo
Apr 15 '13 at 9:07
A why not working version: stackoverflow.com/questions/21347805/…
– Ciro Santilli 新疆改造中心996ICU六四事件
Nov 8 '14 at 9:33