ASP file Upload principle analysis and implementation example

Source: Internet
Author: User
Abstract: In a/-based application environment, uploading various types of files has always been one of the challenges that plague user file management applications. There are three mechanisms for uploading files in HTTP: RFC1867, PUT, and WebDAV. A common implementation method is to use a new type introduced in RFC1867: File and ADO Stream object. This article discusses the upload methods and implementation principles and provides specific solutions.
Asp file object
Currently, applications based on/mode are quite popular. When you need to transfer files to, one of the common methods is to run FTP and set the default FTP directory of each user to your Web home directory, in this way, you can run the FTP client program and upload files to the specified Web directory. This requires users to understand how to use FTP client programs. Therefore, this solution is only feasible for users who are familiar with FTP and are experienced.
If we can integrate the file upload function with the Web so that users can complete the upload task only on the Web, it will be very convenient for them. However, since File System Object can only transmit text files, ASP's biggest problem is File upload. The following describes how to upload files on an HTTP-based webpage.
I. Three mechanisms for uploading via HTTP
HTTP Upload has three mechanisms: RFC1867, PUT, and WebDAV.
PUT introduces a new HTTP verb in HTTP 1.1. When the web receives an http put and object name, it verifies the user, receives the HTTP stream content, and directly saves it to the web. This may cause damage to a web site, and also lose the biggest advantage of HTTP: programmability. In the case of PUT, handle the request by yourself: there is no space for CGI or ASP applications to intervene. The only way for your application to capture PUT is at the lower-layer operation and ISAPI filtering layer. Due to the corresponding reasons, the PUT application is very limited.
WebDAV allows distributed authentication and translation of web content. It introduces several new HTTP verbs that allow uploading, locking/unlocking, registering/verifying web content over HTTP. In Office 2000, "Save to web" is implemented through WebDAV. If everything you are interested in is uploading content, the WebDAV application is excellent and solves many problems.
However, if you need to upload files in your web application, WebDAV is useless to you. Like http put, those WebDAV verbs are interpreted, not web applications. You need to work on the ISAPI filter layer to access these verbs of WebDAV and explain the content in your application.
RFC1867 (http://www.ietf.org/rfc/rfc1867.txt) was finally accepted by W3C in HTML3.2 as a recommended standard. It is a very simple but powerful idea: define a new type in form fields.
<Input type = "FILE">
In addition, different encoding schemes are added to the form itself, and the typical ones are no longer used:

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.