With classic ASP, uploading a file from the client to a server required one of three approaches: use of a third-party COM component, use of a custom-written component, or (messy) script code. The easiest option providing the most features was to use a third-party COM component, such as SA-FileUp or ASPUpload. Problems with using the COM model for Web application components are numerous. First off, these components must be registered (generally using the regsvr32.exe tool) before they can be used from a conventional ASP application. Remote administration of these types of applications is not possible, because the registration tool must be run locally on the server. These components remain locked on disk once they are loaded by an application, and the entire Web server must be stopped before these components can be replaced or removed. Furthermore, these third-party COM components cost money.
ASP.NET easily allows developers to provide upload support without the need of any COM component. This is accomplished via the HtmlInputFile class in the .NET Framework. An instance of this class can be created and used easily through an ASP.NET Web page in just a few lines of code. In this article we'll examine how to upload a file from the client to the Web server using ths server control. We'll also examine how to add some extra functionality, such as creating the upload directory.