📄 pic_upfile.asp
字号:
<!--#include file="upload.inc"-->
<html>
<head>
<title>文件上传</title>
<style type="text/css">
<!--
A:visited{TEXT-DECORATION: none}
A:active{TEXT-DECORATION: none}
A:link{color: #000000; TEXT-DECORATION: none}
A:hover {
color: #FF6600;
}
A{FONT: 9pt 宋体; COLOR: #333333 ; TEXT-DECORATION: none}
TD{font-size:9pt;line-height:100%;}
body {
font-family: "宋体";
font-size: 9pt;
}
-->
</style>
</head>
<body text="#000000" leftmargin="0" topmargin="0" bgcolor="#F4EEE4">
<script>
parent.document.forms[0].Submit.disabled=false;
</script>
<table width="100%" border="0" cellspacing="0" cellpadding="0" bordercolor="#CCCCCC">
<tr>
<td width="388" align="left" valign="middle" height="30">
<%
Const MaxFileSize=300 '上传文件大小限制
Const UpFileType="gif|jpg|png" '允许的上传文件类型
dim upload,file,formName,formPath,filename,fileExt
set upload=new upload_5xSoft ''建立上传对象
formPath=upload.form("filepath")
''在目录后加(/)
if right(formPath,1)<>"/" then formPath=formPath&"/"
for each formName in upload.file ''列出所有上传了的文件
set file=upload.file(formName) ''生成一个文件对象
if file.filesize<10 then
response.write "<font class=14p>请先选择你要上传的文件 [ <a onclick=history.go(-1) style='cursor: hand' class=14p>重新上传</a> ]</font>"
response.end
end if
if file.filesize>(MaxFileSize*1024) then
response.write "<font class=14p>文件大小超过了限制 "&CStr(MaxFileSize)&"K [ <a onclick=history.go(-1) style='cursor: hand' class=14p>重新上传</a> ]</font>"
response.end
end if
fileExt=lcase(right(file.filename,3))
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
response.write "<font class=14p>只允许上传:" & UpFileType &" 文件类型 [ <a onclick=history.go(-1) style='cursor: hand' class=14p>重新上传</a> ]</font>"
response.end
end if
randomize
ranNum=int(90000*rnd)+10000
filename=formPath&year(now)&month(now)&day(now)&ranNum&"."&fileExt
if file.FileSize>0 then ''如果 FileSize > 0 说明有文件数据
file.SaveAs Server.mappath(FileName) ''保存文件
response.write "<script>parent.WBTB_Composition.document.body.innerHTML+='<br><img border=0 src="&filename&">'</script>"
end if
set file=nothing
next
set upload=nothing ''删除此对象
Response.Write "<font color=green>恭喜:您已经成功上传图片!</font>『<a href='pic_upload.asp'>继续上传</a>』"
%>
</td>
</tr>
</table>
</body>
</html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -