Sample Code
//Check that the file is not null
if (uploadfile.PostedFile != null)
{
// process the post file logic here.
//Example of saving the file as another file
this.uploadfile.PostedFile.SaveAs("C:\filename");
//Example of getting the name of the file
string filename = System.IO.Path.GetFileName(this.uploadfile.PostedFile.FileName);
}
But the catch of this method is that the file size is limited to 4 MB. In .NET framework 2.0, this file size can be adjusted easily. However, .NET 1.1 framework users have to add this line in the web.config file
< httpRuntime ="10000" executionTimeout="54000" >
This will increase the lenght of the file to 10 MB (recommended not more than 20 MB) and increase the time allowed to process the bigger file accordingly.
No comments:
Post a Comment