%@language=vbscript codepage=936 %> % <%if session("admin")="" then response.Write "" response.End end if %> <% const upload_type=0 '上传方法:0=无惧无组件上传类,1=FSO上传 2=lyfupload,3=aspupload,4=chinaaspupload const SaveUpFilesPath="upfile" const SaveUpFilesPath2="../upfile" '===================== 西贝修改多媒体素材插件修改 01 开始 ======================= '------------------------- 增加了可上传文件的类型 --------------------------- const UpFileType="jpg|gif|bmp|png|swf|rm|ram|ra|mp3|mpg|asf|wmv|wma" '--------------------- 西贝修改多媒体素材插件修改 01 结束 ----------------------- const EnableUploadFile="Yes" const MaxFileSize=402400 dim upload,oFile,formName,SavePath,filename,fileExt,oFileSize,strJS dim EnableUpload dim arrUpFileType dim ranNum dim msg,FoundErr dim PhotoUrlID msg="" FoundErr=false EnableUpload=false %>
<% if EnableUploadFile="No" then response.write "系统未开放文件上传功能" else select case upload_type case 0 call upload_0() '使用化境无组件上传类 case else 'response.write "本系统未开放插件功能" 'response.end end select end if %> <% sub upload_0() '使用化境无组件上传类 set upload=new upfile_class ''建立上传对象 upload.GetData(104857600) '取得上传数据,限制最大上传100M if upload.err > 0 then '如果出错 select case upload.err case 1 response.write "请先选择你要上传的文件!" case 2 response.write "你上传的文件总大小超出了最大限制(100M)" end select response.end end if 'PhotoUrlID=Clng(trim(upload.form("PhotoUrlID"))) 'if PhotoUrlID>0 then SavePath = SaveUpFilesPath2 '存放上传文件的目录 'else 'SavePath = SaveUpFilesPath '存放上传文件的目录 'end if if right(SavePath,1)<>"/" then SavePath=SavePath&"/" '在目录后加(/) for each formName in upload.file '列出所有上传了的文件 EnableUpload=False set ofile=upload.file(formName) '生成一个文件对象 oFileSize=ofile.filesize if oFileSize<100 then msg="请先选择你要上传的文件!" FoundErr=True elseif oFileSize>(MaxFileSize*1024) then msg="文件大小超过了限制,最大只能上传" & CStr(MaxFileSize) & "K的文件!" FoundErr=true end if fileExt=lcase(ofile.FileExt) arrUpFileType=split(UpFileType,"|") for i=0 to ubound(arrUpFileType) if fileEXT=trim(arrUpFileType(i)) then EnableUpload=true exit for end if next if fileEXT="asp" or fileEXT="asa" or fileEXT="aspx" then EnableUpload=false end if if EnableUpload=false then msg="这种文件类型不允许上传!\n\n只允许上传这几种文件类型:" & UpFileType FoundErr=true end if strJS="" response.write "素材上传成功!素材大小为:" & cstr(round(oFileSize/1024)) & "K" '===================== 西贝修改多媒体素材插件修改 02 开始 ======================= select case PhotoUrlID case 0 strJS=strJS & "parent.document.myform.PhotoUrl_Thumb.value='" & filenameStr & "';" & vbcrlf 'strJS=strJS&"go.history(-1);"&vbcrlf; strJS=strJS & "parent.document.myform.PhotoSize_Thumb.value='" & cstr(round(oFileSize/1024)) & "';" & vbcrlf case 1 call getThumbPhoto() strJS=strJS & "parent.document.myform.PhotoUrl.value='" & fileName & "';" & vbcrlf strJS=strJS & "parent.document.myform.PhotoSize.value='" & cstr(round(oFileSize/1024)) & "';" & vbcrlf case 2 call getThumbPhoto() strJS=strJS & "parent.document.myform.PhotoUrl2.value='" & fileName & "';" & vbcrlf strJS=strJS & "parent.document.myform.PhotoSize2.value='" & cstr(round(oFileSize/1024)) & "';" & vbcrlf case 3 call getThumbPhoto() strJS=strJS & "parent.document.myform.PhotoUrl3.value='" & fileName & "';" & vbcrlf strJS=strJS & "parent.document.myform.PhotoSize3.value='" & cstr(round(oFileSize/1024)) & "';" & vbcrlf case 4 call getThumbPhoto() strJS=strJS & "parent.document.myform.PhotoUrl4.value='" & fileName & "';" & vbcrlf strJS=strJS & "parent.document.myform.PhotoSize4.value='" & cstr(round(oFileSize/1024)) & "';" & vbcrlf end select '--------------------- 西贝修改多媒体素材插件修改 02 结束 ----------------------- else strJS=strJS & "alert('" & msg & "');" & vbcrlf strJS=strJS & "history.go(-1);" & vbcrlf end if strJS=strJS & "" & vbcrlf response.write strJS set file=nothing next set upload=nothing end sub '===================== 西贝修改多媒体素材插件修改 03 开始 ======================= function getThumbPhoto() if instr("wav,mid,swf,mp3,mp4,mpg,mpeg,wmv,asf,rm,ra,ram",fileExt)>0 then response.write(fileExt) select case fileExt case "swf" strJS=strJS & "parent.document.myform.PhotoUrl_Thumb.value='UploadThumbs/filetype_flash.gif';" & vbcrlf strJS=strJS & "parent.document.myform.PhotoSize_Thumb.value='10';" & vbcrlf case "rm","ra","ram" strJS=strJS & "parent.document.myform.PhotoUrl_Thumb.value='UploadThumbs/filetype_rm.gif';" & vbcrlf strJS=strJS & "parent.document.myform.PhotoSize_Thumb.value='10';" & vbcrlf case else strJS=strJS & "parent.document.myform.PhotoUrl_Thumb.value='UploadThumbs/filetype_media.gif';" & vbcrlf strJS=strJS & "parent.document.myform.PhotoSize_Thumb.value='10';" & vbcrlf end select end if end function '--------------------- 西贝修改多媒体素材插件修改 03 结束 ----------------------- %>