ASP program instance for uploading files in HTTP mode

Source: Internet
Author: User
Tags file upload http file upload iis
(from the Computer World journal)
1. HTTP-mode File upload
----File Upload (upload) is a frequent problem in the production of Web sites, most of the friends who often surf the internet have used the email sent by the web. The operation is basically this: when pasting is selected , enter the absolute path to the local file directly or press the browser button to browse for the file you want to paste, and then confirm it. In this process, the HTTP file upload is actually implemented. The BROWSER button appears as "bangs." In the Chinese version of Netscape and IE4. The upload of files from client to server is supported by the Common Gateway Interface (CGI) of the HTTP protocol. This upload requires both the browser and the Web server to support RFC18 Netscape's Web server and browser, as well as IE4.0, support CGI uploads, but Microsoft's Web server IIS does not yet provide such functionality. That is to say, if I If you want to use ASP to implement file uploads, you must also configure IIS. You can download such active Server componet online, or use development tools such as VB to write a Kind of active Server componet to support Rfc1867. Because the use of HTTP upload files for users is the most direct and convenient, I believe that the following ASP examples will be interested.

2. ASP Programming Example
 

----in order to have an intuitive understanding of HTTP upload, it is best to actually run the following example. This simple example has two files. One is upload.html. , one is up.asp. Upload.html has a form that has two buttons "Browse ..." and "upload", where the user enters a file in the text box on the local absolute path or by browsing through the selected file. Download button to upload the file. And up.asp on IIS will save the file to the specified path on the server.

----2.1 upload.html File

< HTML >
< head >< TITLE > Please upload file </title >
< BODY >

< form enctype= "Multipart/form-data"
Method= "POST" action= "up.asp" >

Enter the name of the upload file: < input type= "file" name= "F1" >< br >

< input type= "submit" value= "Upload" >

</form >

</body >


2.2 up.asp File
<%@ language= "VBSCRIPT"% >

< HTML >< head >

< TITLE > Upload file Test </title >


< BODY >

Your file has been uploaded successfully!. < br >

<% Set UPL = Server.CreateObject ("softartisans.fileup")% >

<% UPL. SaveAs "d:\upload\test.out"% >< BR >
File length: <%=UPL. totalbytes% >
</body >


 

----2.3 Examples illustrate

----The FORM must have enctype= "Multipart/form-data" in HTML.

----< INPUT type= "FILE" > is also required.

----When the form is confirmed, the browser will transfer the contents of the specified file.

----in the ASP actually only two statements in the implementation of the upload

----<% Set UPL = Server.CreateObject ("softartisans.fileup")% >

----<% UPL. SaveAs "D:\upload\test.out"% >

----The first statement uses a Softartisans.fileup object to create an instance named UPL, where
An active Server componet called Sa-fileup. The second statement saves the uploaded content on the server.

----To run this example, you need to download this active Server to the Http://www.serverpages.com/upload site
Componet, and use it to configure Microsoft's IIS or personal Web Server. The above examples of the author in IIS3.0 and I e4,netsapce4.0 run through.



Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.