Upload Large files using asp.net

Posted by Venkat | Labels:

To upload large files in asp.net you have to increase the MaxrequestLength and Executiontimeout of the httpruntime settings of your web.config file.By Default it will upload 4MB

suppose if i want to upload upto 8 MB you have to include this tag in you web.config file , don't change anything in your machine.config files.

httpruntime  maxRequestLength="1048576" executionTimeout="450"


here 1048576 - 1 GB

Validation for FileUploadControl

Posted by Venkat | Labels: ,

To validate the fileupload control use Custom Validator and call this function on ClientValidateFunction property of Custom validator.

You can pass the file extension , Watever you want to allow..

function ValidateSFrontImageUpload(Source, args)
{
var fuData = document.getElementById('<%= FrontSImage_FileUpload.ClientID %>');
var FileUploadPath = fuData.value;

if(FileUploadPath =='')
{
// There is no file selected
args.IsValid = false;
}
else
{
var Extension = FileUploadPath.substring(FileUploadPath.lastIndexOf('.') + 1).toLowerCase();

if (Extension == "jpg" || Extension == "jpeg" || Extension == "png" || Extension == "gif")
{
args.IsValid = true; // Valid file type
}
else
{
args.IsValid = false; // Not valid file type
}
}
}

PayOffers.in