Help and Support

Article ID: 189651 - Last Review: June 12, 2007 - Revision: 7.2

Uploading a file to IIS using a browser

This article was previously published under Q189651
Expand all | Collapse all

SUMMARY

The specification in RFC 1867 "Form-based File Upload in HTML" describes the mechanism by which a file may be uploaded from a Web browser to the server. However, to implement this functionality it is necessary to provide of an server application capable of accepting the POST from a client browser. IIS does not accept data posted to the server but passes on the data to the server application which is responsible for appropriately handling the posted data.

For those using earlier versions of IIS or wanting functionality beyond just writing the inbound file to disk, the following library is provided as a sample on how to implement the parsing mechanism.

Uploadext.exe is a sample ISAPI extension DLL that implements the necessary parsing routines to break up multi-part data forms. This self- extracting executable contains the necessary project files for an ISAPI Extension DLL using Microsoft Visual C++ 5.0. To download this sample, visit the following Microsoft Web site:
http://download.microsoft.com/download/iis40/sample47/1/W9XNT4/EN-US/UPLOADEX.EXE (http://download.microsoft.com/download/iis40/sample47/1/w9xnt4/en-us/uploadex.exe)

MORE INFORMATION

For additional information about how to download Microsoft Support files, click the following article number to view the article in the Microsoft Knowledge Base:
119591  (http://support.microsoft.com/kb/119591/ ) How to Obtain Microsoft Support Files from Online Services
Microsoft scanned this file for viruses. Microsoft used the most current virus-detection software that was available on the date that the file was posted. The file is stored on security-enhanced servers that help to prevent any unauthorized changes to the file. There are three ways to upload files to Microsoft Internet Information Server. One is to use the PUT command with the file content (see 184352  (http://support.microsoft.com/kb/184352/EN-US/ ) in the REFERENCES section below). However, this method requires that the browser supports the PUT command. The second way is to use the POST command with INPUT=FILE for the input type. The mechanism for this is described in detail in RFC 1867. Internet Explorer 3.02 with File Upload Add-on, Internet Explorer 4.x, and Netscape Navigator 4.x support this method. The sample library attached to this article shows how you can implement a similar functionality with ISAPI Extensions. The sample extension will parse out the multi-part data and write to the disk the contents of each part (using the name of the multipart as the file name). To download this sample, visit the following MIcrosoft Web site:
http://download.microsoft.com/download/iis40/sample47/1/W9XNT4/EN-US/UPLOADEX.EXE (http://download.microsoft.com/download/iis40/sample47/1/w9xnt4/en-us/uploadex.exe)
The sample and the classes within the sample makes use of various Standard Template Library (STL) containers. Refer to the Visual C++ 5.0's online documentation regarding STLs.

To test the sample, simply extract the files to a directory, start Visual C++, load the project file (.dsw), and build the .DLL. Once that's accomplished, copy the DLL to the /scripts/ directory of a Web server and the Upload.html file to the /wwwroot/ directory of the same Web server (you may need to edit the Upload.html if you are not using the default paths for IIS). Using either browser supporting "INTPUT=FILE" tag, request the Upload.html from the Web server. Fill out the form and submit the request. If you did not change the source code of the sample DLL, the uploaded files will appear in C:\Temp\.

REFERENCES

For additional information, click the following article number to view the article in the Microsoft Knowledge Base:
184352  (http://support.microsoft.com/kb/184352/ ) How to upload files to the Internet Information Server

APPLIES TO
  • Microsoft Internet Information Server 4.0
  • Microsoft Internet Information Services 5.0
  • Microsoft Internet Server Application Programming Interface 4.0
Keywords: 
kbfile kbhttp kbinfo KB189651

Article Translations

 

Related Support Centers