|
asp.net upload faq
» Intro
» How to
» Quickstart
» Advanced
» Troubleshoot
resources
» Download Source Code
» ASP.NET Upload Control
search site
|
Quickstart: Upload to the filesystem
Share this page with friends, or bookmark it for yourself:
This quickstart will walk you through building a page to handle uploads to the server filesystem, and configuring ASP.NET to accept large uploads. » PrerequisitesAn ASP.NET site with a page you want to use to handle uploads. This example is downloadable as an ASP.NET 2.0 web site solution, but the code and settings described below will work exactly the same in any version of ASP.NET (v1.0-v3.5). » Setting the form enctypeTo set up an ASP.NET page for upload, set the server form's encoding type (enctype) to "multipart/form-data" instead of the default of "application/x-www-form-urlencoded". This switches the form's POST format to an RFC 1867 MIME encoded format instead of the default name value pair format. To set the form's enctype
After setting the enctype, the form element on the page should look like this:
» Adding the HTML file input controlTo allow the user to pick a file, use an HTML file input control. To add an html file input control
The page should now look like this:
» Adding a button with upload handling codeWe'll need a button to submit an upload and attach server side code to handle it. To add a button and wire it up
The page should now look like this:
» Setting up the web.config to handle uploadsTo handle files larger than the default request size (4 MB), add settings to the web.config to control the maximum request size and timeout. For this example, we'll use a 1 GB max request length and a 10 minute timeout. To set up the web.config to handle uploads
© 2010 Krystalware
|
Painless ASP.NET file uploads
|