No component file Upload source code

Source: Internet
Author: User
Tags chr file size file upload save file
Upload | no component | No component upload of source Code Network forum,
The following is a separate code from the Dynamic web forum.

If there is any better use please tell the author
Network Name: NET Sea survivors
qq:54883661
Mail:wuyingke5155@163.com

saveannounce_upload.asp upload Page
------------------------------------
<style type= "Text/css" >
body {font-size:9pt;}
input {font-size:9pt;}
</style>
<title> File Upload </title>
<body>
<form name= "form" method= "POST" action= "saveannouce_upfile.asp" enctype= "Multipart/form-data" >
File
<input type= "File" Name= "File1" size=10>
<input type= "Submit" name= "submit" value= "Upload" >
</form>
</body>

------------------------------------
saveannouce_upfile.asp save files to server
------------------------------------
<!--#include file= "Upload.inc"-->
<title> File Upload </title>
<body>
<%
Dim Upload,file,formname,formpath
Set upload=new upload_5xsoft ' Build upload Object
Formpath=upload.form ("filepath") ' in the Catalogue plus (/)
If Right (formpath,1) <> "/" Then formpath=formpath& "/"
For every formName in Upload.file ' lists all uploaded files
Set File=upload.file (formName) ' generates a File object
If File.filesize<100 Then
Response.Write "<font size=2> Please first select the file you want to upload [<a href=# onclick=history.go ( -1) > re-upload </a>]</font> "
Response.End
End If
If file.filesize>500*1000 then ' set upload file size to 500K
Response.Write "<font size=2> file size exceeded limit 500K [<a href=# onclick=history.go ( -1) > re-upload </a>]</font > "
Response.End
End If
If file. Filesize>0 Then ' if FileSize > 0 indicates file data
File. SaveAs Server.MapPath ("Updata\" &file. FileName) ' Save file
End If
Set file=nothing
Next
Set upload=nothing
Response.Write "<font size=2> File Upload success [<a href=# onclick=history.go ( -1) > Continue uploading </a>]</font>"
%>
</body>
------------------------------------
Upload.inc Establish upload objects
------------------------------------
<script Runat=server language=vbscript>

Dim Upfile_5xsoft_stream

Class Upload_5xsoft

Dim form,file,version

Private Sub Class_Initialize
Dim istart,ifilenamestart,ifilenameend,iend,vbenter,iformstart,iformend,thefile
Dim strdiv,mformname,mformvalue,mfilename,mfilesize,mfilepath,idivlen,mstr
Version= ""
If Request.totalbytes<1 then Exit Sub
Set Form=createobject ("Scripting.Dictionary")
Set File=createobject ("Scripting.Dictionary")
Set Upfile_5xsoft_stream=createobject ("ADODB.stream")
Upfile_5xsoft_stream.mode=3
Upfile_5xsoft_stream.type=1
Upfile_5xsoft_stream.open
Upfile_5xsoft_stream.write Request.BinaryRead (request.totalbytes)

VBENTER=CHR (&AMP;CHR) (10)
Idivlen=instring (1,vbenter) +1
Strdiv=substring (1,idivlen)
Iformstart=idivlen
Iformend=instring (Iformstart,strdiv)-1
While Iformstart < Iformend
Istart=instring (Iformstart, "name=" "")
Iend=instring (Istart+6, "" "")
Mformname=substring (istart+6,iend-istart-6)
Ifilenamestart=instring (iend+1, "filename=" "")
If Ifilenamestart>0 and Ifilenamestart<iformend then
Ifilenameend=instring (ifilenamestart+10, "" "")
Mfilename=substring (IFILENAMESTART+10,IFILENAMEEND-IFILENAMESTART-10)
Istart=instring (Ifilenameend+1,vbenter&vbenter)
Iend=instring (Istart+4,vbenter&strdiv)
If Iend>istart Then
Mfilesize=iend-istart-4
Else
Mfilesize=0
End If
Set Thefile=new FileInfo
Thefile.filename=getfilename (Mfilename)
Thefile.filepath=getfilepath (Mfilename)
Thefile.filesize=mfilesize
Thefile.filestart=istart+4
Thefile.formname=formname
File.add Mformname,thefile
Else
Istart=instring (Iend+1,vbenter&vbenter)
Iend=instring (Istart+4,vbenter&strdiv)

If Iend>istart Then
Mformvalue=substring (istart+4,iend-istart-4)
Else
Mformvalue= ""
End If
Form. ADD Mform

Large-Scale Price Reduction
  • 59% Max. and 23% Avg.
  • Price Reduction for Core Products
  • Price Reduction in Multiple Regions
undefined. /
Connect with us on Discord
  • Secure, anonymous group chat without disturbance
  • Stay updated on campaigns, new products, and more
  • Support for all your questions
undefined. /
Free Tier
  • Start free from ECS to Big Data
  • Get Started in 3 Simple Steps
  • Try ECS t5 1C1G
undefined. /

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.