XML skills file upload 4

Source: Internet
Author: User
The following code is used on the server to provide the same object to the server. % @ LANGUAGE = VBScript % OptionExplicitResponse. Expires = 0' defines variables and objects. Dimado_streamdimxml_domdimxml_file1 'creates a Stream object. Server

The following code uses the same object to provide the server with a real Upload processing function.


<% @ LANGUAGE = VBScript %>
<% Option Explicit
Response. Expires = 0

'Define variables and objects.
Dim ado_stream
Dim xml_dom
Dim xml_file1

'Create Stream object
Set ado_stream = Server. CreateObject ('adodb. stream ')
'Create an XMLDOM object from the Request object
Set xml_dom = Server. CreateObject ('msxml2. domdocument ')
Xml_dom.load (request)
'Read the node that contains binary data
Set xml_file1 = xml_dom.selectSingleNode ('root/file1 ')

'Open the Stream object and store the data in it.
Ado_stream.Type = 1' 1 = adTypeBinary
Ado_stream.open
Ado_stream.Write xml_file1.nodeTypedValue
'File storage disks'
Ado_stream.SaveToFile 'C: \ tmp \ upload1.doc ', 2' = adSaveCreateOverWrite
Ado_stream.close

'Burn objects
Set ado_stream = Nothing
Set xml_dom = Nothing
'Return information to the browser
Response. Write 'upload successful! '
%>

You can also apply the Stream object to put the data in the BLOB field of the database.

Benefits of using this method

Does not cause page conversion.
No private components are required.
You can upload multiple files at the same time.

This program is written in a pure script and can be easily inserted into other code without the cooperation of any HTML object. This logic can also be implemented in any language supporting the COM scale.

System Security considerations

This method can only be applied to internal networks, because it needs to set the security level of IE5 to "low ". Required:

Promise scripts and ActiveX objects. This setting promises the browser to execute a JScript statement similar to 'myobj = new activexobject;

You must promise to visit the data source through the domain. This setting promises to apply the Stream object on the client. You must also install ms xml dom 3.0 and MDAC 2.5 on both the server and client.


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.