Implement synchronous Upload of images and text using pure asp code
Source: Internet
Author: User
I saw an article on the Internet, modified it and combined it with xml to achieve synchronous Upload of image text!
3 files in total: upload.htm, uploadtext. asp, uploadimg. asp
Create an access database named text. mdb and a table named imgtable
The fields include text1 and img, and an incremental id field.
The code is as follows:
Upload.htm
<Html>
<Head>
<Title> synchronous Upload of image text </title>
<Meta name = "dongbao" content = "text/html; charset = gb2312" http-e
Quiv = "Content-Type">
<Script language = "javascript">
<! -- Hide me
Function upload ()
{
Var xmlhttp = new ActiveXObject ("Microsoft. XmlHttp ");
Var textcontent = "<textcontent> <name>" + document. formtext. name. va
Lue + "</name> </textcontent> ";
Xmlhttp. Open ("POST", "uploadtext. asp", false );
Xmlhttp. Send (textcontent );
Return true;
}
// Show me -->
</Script>
</Head>
<Body>
<Form action = "uploadimg. asp" enctype = "multipart/form-data" method
= "Post" onsubmit = "return upload ();">
<Input name = "picture" type = "file"/>
<Input type = "submit"/>
</Form>
<Form name = "formtext">
<Input name = "name"/>
</Form>
</Body>
</Html>
Showpicture. asp:
<% @ Language = VBScript %>
<%
Set conn = server. CreateObject ("adodb. connection ")
Dbpath = server. MapPath ("test. mdb ")
Conn. Open "driver = {Microsoft Access Driver (*. mdb)}; dbq =" & dbpath
Set xmldom = server. CreateObject ("Microsoft. XmlDom ")
Xmldom. load (request)
Name = xmldom. selectsinglenode ("// name"). text
SQL = "insert into imgtable (text1) values ('" & name &"')"
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