开发者

retrieve text from form in classic ASP

I would like to have a form input which loads a file (XML) and posts it to another in a ASP page. I am not sure how to "get" the data from the form. This is the very basic form page. The ASP page is returning error 500

<FORM METHOD=POST ENCTYPE="multipart/form-data" ACTION="/v/testasp300.asp">
    File to upload: <INPUT TYPE=FILE NAME="upfile"><BR>
    <INPUT TYPE=SUBMIT VALUE="Submit">
</FORM>

This is the relevant part of the ASP page.

Dim objXML, x
Set objXML = CreateObject("MSXML2.DOMDocument")
objXML= Request.QueryString("upfile")
objXML.setProperty "Sel开发者_Python百科ectionLanguage", "XPath"

Dim xmldoc: set xmldoc = CreateObject("MSXML2.DomDocument")
xmldoc.async = false
Dim instruction
Set instruction = xmldoc.createProcessingInstruction("xml", "version=""1.0"" encoding=""UTF-8"" standalone=""yes""")
xmldoc.appendChild instruction 

Dim rss: set rss = xmldoc.createElement("rss")
xmldoc.appendChild rss

Dim itemNode2: Set itemNode2 = xmldoc.selectSingleNode(".//rss")
Dim name: Set name = xmldoc.createAttribute("xmlns:g") 
name.Value = "http://base.google.com/ns/1.0" 
itemNode2.attributes.setNamedItem(name)

Dim itemNode: Set itemNode = xmldoc.selectSingleNode(".//rss")
Dim version: Set version = xmldoc.createAttribute("version") 
version.Value = "2.0" 
itemNode.attributes.setNamedItem(version)

Dim channel: set channel = xmldoc.createElement("channel")
rss.appendChild channel

For Each x In objXML.documentElement.selectNodes(".//SAVED_EXPORT")


Files are uploaded from a browser using a mime multipart encoded entity body. This is a format of entity body that ASP does not understand, therefore neither Request.QueryString nor Request.Form is of use to you.

Hence in order to consume the received data your page will need to interact directly with binary data in the request. Since you cannot install any components on the server you will need a solution that would work on a vanilla ASP server install.

Fundementally what is needed is to extract useful info from the Mime headers (such as filename) then to send the mime body part to a file. This is a lot to invent yourself but there are a number of free chunks of ASP includes out there that can do this for you. Here are links to a couple:-

  • http://www.planet-source-code.com/vb/scripts/ShowCode.asp?txtCodeId=7361&lngWId=4#zip
  • http://www.codeproject.com/KB/asp/vbsupload.aspx

Both of these are mainly interested in dumping the file to the file system, however from there you should be able to load the XML and continue your work.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜