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 (&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