This is a migrated thread and some comments may be shown as answers.
Changing Upload Size
8 Answers 209 Views
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
patrick
Top achievements
Rank 1
patrick asked on 17 Mar 2011, 02:15 PM
After looking over the Upload feature it is something I would love to implement for a project I am working on.  A few questions: Is there a way to increase or decrease the maximum file upload attribute?  Currently everything I read states 10mb max per file at all times.  If its not available currently can someone point me to the direction of where the current settings of 10mb are hardcoded into the extensions so I can make appropriate modifications?

Answers to these few questions would be greatly appreciated!

8 Answers, 1 is accepted

Sort by
0
patrick
Top achievements
Rank 1
answered on 17 Mar 2011, 02:35 PM
http://www.telerik.com/help/aspnet-mvc/telerik-ui-components-upload-troubleshooting.html

I should have kept reading before posting.
I guess the update to my question would be as follows:
If I change settings to allow a large file, is there a way to (using the telerik uploader and commands) limit a file's size allowed to be queued in a specific list?
IE: I setup an allowance of 20mb files, but in this instance of the telerik file uploader I want to cap out the allowed size at 5mb (numbers are arbitrary, no code to post as I am asking hypothetically)
0
T. Tsonev
Telerik team
answered on 19 Mar 2011, 10:31 AM
Hello Patrick,

You can check for the file size in the OnUpload event and cancel it when it exceeds a given limit. But there is a caveat. The file size is only available in browsers that support the new File API - Firefox 4 and Chrome.

<script type="text/javascript">
    var bytesPerMB = 1048576;
  
    function onUpload(e) {
        // Array with information about the uploaded files
        var files = e.files;
  
        // Check the extension of each file and abort the upload if it is not .jpg
        $.each(files, function(file) {
            if (file.size && (file.size > 5 * bytesPerMB)) {
                alert("File size exceeds the 5MB limit")
                e.preventDefault();
                return false;
            }
        });
    }
</script>

With this in mind you should also implement a server-side validation for browsers that do not provide file size information.


Kind regards,
Tsvetomir Tsonev
the Telerik team
0
Simon
Top achievements
Rank 1
answered on 11 Apr 2011, 07:42 PM
Couldn't get the above validation code to work. $.each in jQuery iterates over the document element no, not the captured collection?

Anyway, the below works for anyone scratching their head:

var bytesPerMB = 1048576;
 
function onUpload(e) {
    // Array with information about the uploaded files
    var files = e.files;
 
    // Check the extension of each file and abort the upload if the file is larger than a prescribed size, 5MB in this case
    $(files).each(function (index, file) {
        if (file.size && (file.size > 5 * bytesPerMB)) {
            alert("Your image is greater than 5MB in size. Please select a smaller image")
            e.preventDefault();
            return false;
        }
    });
}
0
Samir
Top achievements
Rank 1
answered on 25 May 2011, 07:58 AM
Hi Tsvetomir,

I tried your code but it returns a file size of null as per the attached picture. I am using MVC 3 version for 2011 Q1. Please would you help.
This size showing null even for images with more than 500kb in size.

Thanks,
Samir
0
Atanas Korchev
Telerik team
answered on 25 May 2011, 08:35 AM
Hello Simon,

From your screenshot it looks that you are using Internet Explorer. As Tsvetomir said the file size is available only in browsers that support the new File API - Firefox 4 and Chrome.

All the best,
Atanas Korchev
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Gurpreet
Top achievements
Rank 1
answered on 22 Aug 2011, 07:10 PM
Hi

I'm facing the same issue.

In order to get the file size in IE, what approach should I follow.

Thanks
Gurpreet
0
Atanas Korchev
Telerik team
answered on 22 Aug 2011, 09:05 PM
Hi Gurpreet,

 File size is not supported in Internet Explorer due to lacking implementation of the required HTML5 API. Unfortunately we cannot offer a workaround for retrieving the file size on the client-side. You need to perform file size checks on the server side.

Regards,
Atanas Korchev
the Telerik team

Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>

0
sujith
Top achievements
Rank 1
answered on 08 Nov 2012, 01:48 AM
Any update on this? Does the latest telerik assemblies still doesn't support IE 8 ? 
Tags
Upload
Asked by
patrick
Top achievements
Rank 1
Answers by
patrick
Top achievements
Rank 1
T. Tsonev
Telerik team
Simon
Top achievements
Rank 1
Samir
Top achievements
Rank 1
Atanas Korchev
Telerik team
Gurpreet
Top achievements
Rank 1
sujith
Top achievements
Rank 1
Share this question
or