Home | Articles|Namespace|Interview Questions|Tools|Jobs|Projects|Community
Asp.net Tutorials

»Dotnet Ads
»Message Boards
Message Boards
Dotnet Books

»Member Details
Register
Login
LogOut
Submit Code
Submit Jobs
Submit Projects

»Competition
Community
Winners
Prizes
Write For Us
Members

»Other Resources
Links
Dotnet Resources

Uploading a file in asp.net

In this small article i will show you how to uploading a file from asp.net

For uploading files we have to set the form mimetype as below. Otherwise file data could not be sent



Now add the html file control to the page



Then add a button to upload a file once a file is selecte




In the onclick event of the upload button add

private void uploadButton_Click(object sender, System.EventArgs e)
{
//check to see if a file is uploaded
if(File1.PostedFile != null)
{
//save it

File1.PostedFile.SaveAs("filename.txt");

}

}

That's it :)


Have a Question and dont know the answer post it below and get answers in minutes

Due to spam this feature is disabled
To get answers fast , make sure you enter a detailed subject for example: "DataGrid issues need answer" not "DataGrid"

Subject:

Catjegory Name:

Message:



© 2008 dotnetwatch.com -- Privacy policy