asp.net upload faq
» How to
» Download Source Code
» ASP.NET Upload Control
Upload files using an RFC 1867 POST request with HttpWebRequest/WebClient
You don't have to write any code to format or upload browser based uploads – the browser takes care of that. But what if you want to simulate a browser upload request, or manually upload using code? To do this, you need to create and submit a request using the RFC 1867 multipart/mime-encoded formatting standard.
There are two ways to upload files in .NET:
Simple uploading with WebClient.UploadFile
Call the method, passing in the URL and the name of the file to upload:
Advanced uploading with HttpWebRequest
The UploadHelper library is part of the source code download available on this site. This library provides an Upload method that can upload multiple files and form variables. It uses streams and other techniques so files are never loaded into memory, dramatically reducing memory usage and increasing scalability and performance. Grab the source archive, build it, and add a reference to the UploadHelper assembly to your project.
To use the UploadHelper library, set up your request parameters and call the UploadHelper.Upload method:
If you want more control over the request, to set credentials or cookies for example, you can create the request object manually, set it up, and then pass it to the other Upload method overload to do the actual uploading:
© 2013 Krystalware
Painless ASP.NET file uploads