📄 upfile.asp
字号:
<!--#include FILE="conn.asp"-->
<!--#include FILE="upload.inc"-->
<%
if session("user_id")="" then
response.write "<script language='javascript'>" & VbCRlf
response.write "alert('非法操作!');" & VbCrlf
response.write "history.go(-1);" & vbCrlf
response.write "</script>" & VbCRLF
else
if request("action")="upload" then
if session("goods_id")<>"" then
set rs = server.CreateObject ("Adodb.recordset")
sql = "select * from goods_info where goods_id="&session("goods_id")
rs.open sql,conn,1,3
if rs("goods_pic")<>"" then
tempfpath=rs("goods_pic")
FiLePaTh = Server.MapPath(tempfpath)
Set fso = CreateObject("Scripting.FileSystemObject")
fso.DeleteFile(FiLePaTh)
Set fso = nothing
rs.close
set rs = nothing
end if
session("goods_id")=""
end if
user_id="user_id_"&session("user_id")&"_"
nowtime=now()
sj=cstr(year(nowtime))+"-"+right("0"+cstr(month(nowtime)),2)+"-"+right("0"+cstr(day(nowtime)),2)
dim upload,file,formName,formPath,iCount
set upload=new upload_F
function MakedownName()
dim fname
fname = now()
fname = replace(fname,"-","")
fname = replace(fname," ","")
fname = replace(fname,":","")
fname = replace(fname,"PM","")
fname = replace(fname,"AM","")
fname = replace(fname,"上午","")
fname = replace(fname,"下午","")
fname = int(fname) + int((10-1+1)*Rnd + 1)
MakedownName=fname
end function
formPath="uploadfiles/"
iCount=0
for each formName in upload.file ''列出所有上传了的文件
set file=upload.file(formName) ''生成一个文件对象
if file.FileSize<100 then
response.write "上传发生错误,请先选择你要上传的文件! [ <a href=# onclick=history.go(-1)>重新上传</a> ]"
response.end
end if
if file.FileSize>512000 then
response.write "上传发生错误,文件大小超过了500K![ <a href=# onclick=history.go(-1)>重新上传</a> ]"
response.end
end if
fileExt=lcase(right(file.filename,4))
if fileEXT<>".gif" and fileEXT<>".jpg" and fileEXT<>".bmp" then
response.write "上传发生错误,文件格式不正确![ <a href=# onclick=history.go(-1)>重新上传</a> ]"
response.end
end if
if file.FileSize>0 then ''如果 FileSize > 0 说明有文件数据
newname=user_id&MakedownName()&"."&mid(file.FileName,InStrRev(file.FileName, ".")+1)
file.SaveAs Server.mappath(formPath&newname) ''保存文件
iCount=iCount+1
else
response.write "未找到文件 <A HREF=javascript:history.back(1)>返回</A>"
end if
next
Response.Write("<SCRIPT>parent.input.goodspic.value+='uploadfiles/"&newname&"'</SCRIPT>")
else
%>
<style type="text/css">
<!--
input {
border: 1px solid;
}
-->
</style>
<form action="upfile.asp?action=upload" method="POST" enctype="multipart/form-data" name=myform>
<div align="left">
<table border="0" cellspacing="0" style="border-collapse: collapse" width="100%" bordercolorlight="#FFEEB3" cellpadding="0" bordercolordark="#FFEEB3">
<tr>
<td><input type="file" name="cimg" size="15" value="浏览">
<input type="submit" value="上传" name="B1" isshowprocessbar="True">
(gif或jpg格式,200K以下)</td>
</tr>
</table>
</div>
</form>
<%
end if
end if
%>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -