I am using the upload widget on ASP.Net when I submit the form. Due to the file size limit allowed by the server I need a way to cancel the submit if the combined size of the files selected for upload as above a set limit. Any help is appreciated.
Wade
Wade
4 Answers, 1 is accepted
0
Accepted
Hello Wade,
You can use the Upload's select event, iterate through all files in the e.files array and check the size property of each file (object).
http://www.kendoui.com/documentation/ui-widgets/upload/events.aspx
However, note that due to browser limitations, this will not work in Internet Explorer, as it simply does not report the file size.
Regards,
Dimo
the Telerik team
You can use the Upload's select event, iterate through all files in the e.files array and check the size property of each file (object).
http://www.kendoui.com/documentation/ui-widgets/upload/events.aspx
However, note that due to browser limitations, this will not work in Internet Explorer, as it simply does not report the file size.
Regards,
Dimo
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0

William
Top achievements
Rank 1
answered on 03 Feb 2012, 04:05 PM
Well, not what I wanted to hear, but it is what it is. Thanks.
Wade
Wade
0

Einar
Top achievements
Rank 1
answered on 05 Nov 2014, 10:06 PM
Dimo,
I want to enforce 5MB size across all files (previously selected and currently selected).
1. I select a 3mb file. (e.files = 1 file)
2. I then select a 1mb file (e.files = 1 file)
3. I then select a 10mb file. (e.files = 1 file)
Does the Upload widget api expose previously selected files with their sizes or should I store this information myself?
For this to work I'd need file sizes of previously selected files so that I can add that sum to the file(s) I'm trying to select to see if it exceeds 5mb.
I want to enforce 5MB size across all files (previously selected and currently selected).
1. I select a 3mb file. (e.files = 1 file)
2. I then select a 1mb file (e.files = 1 file)
3. I then select a 10mb file. (e.files = 1 file)
Does the Upload widget api expose previously selected files with their sizes or should I store this information myself?
For this to work I'd need file sizes of previously selected files so that I can add that sum to the file(s) I'm trying to select to see if it exceeds 5mb.
0
Hello Einar,
This is possible. Here is how to do it:
- go to http://demos.telerik.com/kendo-ui/upload/index
- select some files 2-3 times, so that they appear as 2-3 items in the Upload file list
- open the browser's Javascript console and execute:
In the console, you will get 2-3 arrays of objects. Each object will have a size field.
Regards,
Dimo
Telerik
This is possible. Here is how to do it:
- go to http://demos.telerik.com/kendo-ui/upload/index
- select some files 2-3 times, so that they appear as 2-3 items in the Upload file list
- open the browser's Javascript console and execute:
$(
"#files"
).data(
"kendoUpload"
).wrapper.find(
".k-file"
).each(
function
(idx, element) {
console.log($(element).data(
"fileNames"
));
});
In the console, you will get 2-3 arrays of objects. Each object will have a size field.
Regards,
Dimo
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!