Reputation: 2192
I am working on a project i have used uploadify control for file uploading,i have to set file size limit to 5MB, i've seen its documentation Here
I tried setting 5MB but still when i am selecting file around 3MB it is showing file size error I also tried setting value without any unit (ie 5120) but in that case its also showing file size error when i select even of file 3MB size
Here's my code
var sizelimit = '5MB'; //or '5120'
$('#file_upload').uploadify({
'uploader': ResourceUplodify.Uploader,
'script': ResourceUplodify.ScriptFile,
'cancelImg': ResourceUplodify.CancelImg,
'folder': ResourceUplodify.Folder,
'fileDesc': 'Document Files',
'buttonImg': '../../Content/images/Attach-File.jpg',
'fileExt': '*.pdf;*.doc;*.ppt;*.odt;*.rtf;*.txt',
// 'sizeLimit': 10485760,
'sizeLimit': sizelimit,
'height': 29,
'width': 90,
'buttonText': 'Attach File',
'multi': false,
'auto': false,
'onSelect': function (a, b, c, d, e) {
},
'onComplete': function (a, b, c, d, e) {
// if (d != '1') {
},
'onError': function () {
}
});
I also want to work with session with uploadify,they have shown PHP code for working with session but i dont know how to work with session in C#(using uploadify offcourse)
Working with Session in Uploadify
How can i access value of formdata in MVC3(C# code)
Upvotes: 1
Views: 4188
Reputation: 12721
File size limita management on Uploadify - Aspnet is based on 2 different features:
Server management sets the limit for the size of file that can be accepted by IIS
Client management sets the limit for the size of file that can be sent by browser
Server file limit is set by maxRequestLength parameter in web.config
<httpRuntime requestValidationMode="2.0" maxRequestLength="102400"/>
This si a KByte numeric value, so maxRequestLength="102400" means 100 MB file.
Browser file limit is set by sizeLimitparameter in .uploadify() javascript inizialization
function uploadScript(sessionId, swfUrl, ascxUrl, cancelUrl) {
$('input[type="file"]').each(function (i) {
$(this).uploadify({
'uploader': swfUrl,
'script': ascxUrl,
'scriptData': { 'sessionId': sessionId, 'clientId': $(this).attr("id") }, // $(this).closest("div").attr("id")
'cancelImg': cancelUrl,
'auto': true,
'multi': false,
'fileDesc': 'Tutti i file',
'fileExt': '*.*',
'queueSizeLimit': 90,
'sizeLimit': 100000000,
'buttonText': 'Scegli file',
'folder': '/uploads',
'onAllComplete': function (event, queueID, fileObj, response, data) { }
});
});
}
sizeLimit is a Byte value, so to send a 100 MB file you must consider that 100M = 1024*1024*100.
Upvotes: 1
Reputation: 1038800
The default request size limit in ASP.NET is 4MB.
Make sure you have increased the default value of the request size in your web.config using the <httpRuntime>
element if you want to allow files larger than 4MB to be uploaded:
<system.web>
<!-- 5MD (value is in KB here) -->
<httpRuntime maxRequestLength="5120" />
...
</system.web>
and also if you are hosting on IIS7 you need to set the maxAllowedContentLength
to the same value (in bytes):
<system.webServer>
<security>
<requestFiltering>
<!-- 5MB (value is in bytes here) -->
<requestLimits maxAllowedContentLength="5242880" />
</requestFiltering>
</security>
</system.webServer>
As far as the sessions are concerned, you may find the following post
useful.
Upvotes: 2