<% '读取config中存储的文件上传类型 dim ObjFSO,UploadClass,UploadFileSize,UploadFileType,ok On Error Resume Next set ObjFSO=server.CreateObject("scripting.filesystemobject") Set a=ObjFSO.openTextFile(server.mappath("config.ssln")) UploadClass=a.readline UploadFileSize=a.readline UploadFileType=a.readline a.close set a=nothing set ObjFSO=nothing '读取结束 Server.ScriptTimeOut = 18000 Dim UploadObject,AllowFileSize,AllowFileExt Dim sUploadDir,SaveFileName,PathFileName,FileExtName Dim sAction,sType,AutoRename UploadObject = UploadClass '上传文件对象 --- 0=无组件上传,1=Aspupload3.0组件,2=SA-FileUp 4.0组件 AllowFileSize = UploadFileSize'上传文件大小 AllowFileExt = cstr(UploadFileType) '上传文件类型 AllowFileExt = Replace(Replace(Replace(UCase(AllowFileExt), "ASP", ""), "ASPX", ""), "|", ",") if UploadObject<>999 then %> 文件上传
<% sAction =Trim(Request.QueryString("action")) If sAction ="save" Then Call UploadFile PathFileName = SaveFileName response.write "" response.write "" Else %>
 

允许上传的文件类型:<%=AllowFileExt%>  大小:<%=CStr(AllowFileSize)%> KB
<% End If %>
<% else response.Write("本系统未开放上传功能!") end if Sub UploadFile() Dim Upload,FilePath,sFilePath,FormName,File sUploadDir="sslnfiles" sFilePath = CreatePath(sUploadDir) '按日期生成目录 FilePath = sUploadDir & sFilePath Set Upload = New UpFile_Cls Upload.UploadType = UploadObject '设置上传组件类型 Upload.UploadPath = FilePath '设置上传路径 Upload.MaxSize = AllowFileSize '单位 KB Upload.InceptMaxFile = 10 '每次上传文件个数上限 Upload.InceptFileType = AllowFileExt '设置上传文件限制 'Upload.ChkSessionName = "uploadfile" '执行上传 Upload.SaveUpFile If Upload.ErrCodes<>0 Then Response.write ("") Exit Sub End If If Upload.Count > 0 Then For Each FormName In Upload.UploadFiles Set File = Upload.UploadFiles(FormName) SaveFileName = FilePath & File.FileName Set File = Nothing Next Call OutFilesize(Upload.MaxSize) Else Response.Write ("") Exit Sub End If Set Upload = Nothing End Sub Sub OutFilesize(filesize) Response.Write "文件大小:" & Round(filesize/1024,2) & "kb" & vbCrLf End Sub '================================================ ' 函数名:CreatePath ' 作 用:按月份自动创建文件夹 ' 参 数:fromPath ----原文件夹路径 '================================================ Function CreatePath(fromPath) Dim objFSO, uploadpath uploadpath="" 'uploadpath = Year(Now) & "-" & Month(Now) '以年月创建上传文件夹,格式:2003-8 On Error Resume Next Set objFSO = Server.CreateObject("Scripting.FileSystemObject") If objFSO.FolderExists(Server.MapPath(fromPath & uploadpath)) = False Then objFSO.CreateFolder Server.MapPath(fromPath & uploadpath) End If If Err.Number = 0 Then CreatePath = uploadpath & "/" Else CreatePath = "" End If Set objFSO = Nothing End Function %>