www.gusucode.com > 掌柜网店购物系统 4.0码程序 > admin/UpLoad_guanggao.asp
<!--#include file="upload_guanggao.inc"--> <% filepath="../img/guanggao/" '上传路径 filepathname = "img/guanggao/" set upload=new clsUp '建立上传对象 upload.NoAllowExt="asp;asa;cer;aspx;cs;vb;js;" '设置上传类型的黑名单 upload.AllowExt="gif;jpg;" '设置上传类型的黑名单 upload.GetData (3072000) '取得上传数据,限制最大上传3M if upload.form("act")="uploadfile" then for each formName in upload.File set file=upload.File(formName) fileExt=lcase(file.FileExt) '得到的文件扩展名不含有. if file.filesize<10 then response.write "<span style=""font-family: 宋体; font-size: 9pt"">请先选择你要上传的文件! [ <a href=# onclick=history.go(-1)>重新上传</a> ]</span>" response.end end if if file.filesize>(3000*1024) then response.write "<span style=""font-family: 宋体; font-size: 9pt"">最大只能上传 3000K 的图片文件! [ <a href=# onclick=history.go(-1)>重新上传</a> ]</span>" response.end end if if trim(file.fileext)<>"gif" and trim(file.fileext)<>"jpg" then response.write "<span style=""font-family: 宋体; font-size: 9pt"">只能上传jpg或gif格式的图片,系统将记录你的非法操作! [ <a href=# onclick=history.go(-1)>重新上传</a> ]</span>" response.end end if dtNow=Now() randomize ranNum=int(90000*rnd)+10000 filename1=year(dtNow) & right("0" & month(dtNow),2) & right("0" & day(dtNow),2) & right("0" & hour(dtNow),2) & right("0" & minute(dtNow),2) & right("0" & second(dtNow),2) & ranNum &"."&fileExt filename=filepath&filename1 filelstname=filepathname&filename1 if file.FileSize>0 then ''如果 FileSize > 0 说明有文件数据 upload.SaveToFile formName,Server.mappath(FileName) '这里可以存数据库 response.write "<script>window.opener.document."&upload.form("FormName")&"."&upload.form("EditName")&".value='"&filelstname&"'</script>" %> <script language="javascript"> window.alert("文件上传成功!"); window.close(); </script> <% end if set file=nothing next set upload=nothing end if %>