------------------checkuser.asp---------------- <% if not session("userClass")>=1 then%> <script language=Javascript> <!-- alert("您的权限已无效,请重新登陆!") window.history.go(-1); --> </script> <% response.End end if %>
-----------savefile.asp---------
<!--#INCLUDE FILE="../include/upload.asp"--> <!--#include file="checkUser.asp"--> <% set upload=new upload_5xSoft formPath=formPath set file=upload.file("file1") formPath="../file/" if file.FileSize>0 then '如果 FileSize > 0 说明有文件数据 fileName=file.FileName file.SaveAs Server.mappath(formPath&filename) ''保存文件 end if
set file=nothing %> <script language=Javascript> <!-- alert("文件上传成功!"); window.location="addFile.asp" --> </script>
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(13)&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 mFormName,mFormValue end if
iFormStart=iformEnd+iDivLen iFormEnd=inString(iformStart,strDiv)-1 wend End Sub
Private Function subString(theStart,theLen) dim i,c,stemp upfile_5xSoft_Stream.Position=theStart-1 stemp="" for i=1 to theLen if upfile_5xSoft_Stream.EOS then Exit for c=ascB(upfile_5xSoft_Stream.Read(1)) If c > 127 Then if upfile_5xSoft_Stream.EOS then Exit for stemp=stemp&Chr(AscW(ChrB(AscB(upfile_5xSoft_Stream.Read(1)))&ChrB(c))) i=i+1 else stemp=stemp&Chr(c) End If Next subString=stemp End function
Private Function inString(theStart,varStr) dim i,j,bt,theLen,str InString=0 Str=toByte(va