Upload with implementation file

Source: Internet
Author: User
Upload data source Elite Area straw farmer and other people

Submit.htm

<body>
<form name= "Form1" method= "Post" action= "upload.asp" enctype= "Multipart/form-data" >
<input type=file name= "File1" >
<input type=submit name= "Submit" value= "submitted" >
</form>
</body>
Upload.asp

<%@ Language=vbscript%>
<%
Function Binarytoasi (ByVal varstr)
Asi= ""
For I=1 to 3
ASI=ASI&AMP;CHR (ASCB (MidB (varstr,i,1))
Next
Binarytoasi=asi
End Function

Formsize=request.totalbytes
Formdata=request.binaryread (request.totalbytes) ' Get uploaded data
BCRLF=CHRB (+) & ChrB (10)
Divider=leftb (FORMDATA,CLNG (INSTRB (FORMDATA,BCRLF))-1)

POSITION=INSTRB (Formdata,bcrlf & Bcrlf) +4 ' upload file data start bit
FILESIZE=INSTRB (position+1,formdata,divider)-position-4 ' upload file data length
EXNAMESTART=INSTRB (1,FORMDATA,CHRB (46), 1) +1
EXNAMEEND=INSTRB (EXNAMESTART,FORMDATA,CHRB (34), 1)
EXNAME=MIDB (Formdata,exnamestart,exnameend-exnamestart)

Set Dr=createobject ("ADODB.stream")
Dr. Mode=3:dr. Type=1:dr. Open
Set Dr1=createobject ("ADODB.stream")
Dr1. Mode=3:dr1. Type=1:dr1. Open

Dr. Write Formdata
Dr. Position=position-1
Dr. CopyTo dr1,filesize
Dr1. SaveToFile "D:/mailtemp/temp_" &session ("userid") & "." &binarytoasi (Exname), 2 ' File save
Set Dr=nothing:set dr1=nothing

%>



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.