📄 upfile.asp
字号:
<!--#include file="conn.asp"-->
<!--#include file="usercookies.asp"-->
<!--#include file="config.asp"-->
<%Server.ScriptTimeOut=5000%>
<!--#include file = "cnmai.inc"-->
<%
dim upload,file,formElement,formFile,iCount,fileExt,id,username,formPath,rs,sql,filename
iCount=0
username=request.cookies("cnmai")("username")
set upload = new sjCat_Upload
Set file = upload.file("file1")
id=upload.form("id")
if file.filesize<1 then
response.write "<font size=2>请先选择你要上传的图片 [ <a href=# onclick=history.go(-1)>重新上传</a> ]</font>"
response.end
end if
fileExt=lcase(right(file.filename,4))
if fileEXT<>".gif" and fileEXT<>".jpg" then
response.write "<font size=2>文件格式不对 [ <a href=# onclick=history.go(-1)>重新上传</a> ]</font>"
response.end
end if
if file.filesize>102400 then '这是100K的图片大小数据
response.write "<font size=2>图片大小超过了限制(不大于100K) [ <a href=# onclick=history.go(-1)>重新上传</a> ]</font>"
response.end
end if
filename=formPath&year(now)&month(now)&day(now)&hour(now)&minute(now)&second(now)&fileExt
if file.FileSize>0 then
file.Save2File Server.mappath("uptupian") & "\" & FileName
iCount=iCount+1
end if
set file=nothing
set upload=nothing
dim whichfile,fso,thisfile,my_string,muma
whichfile=server.mappath("uptupian\"& fileName & "")
Set fso = CreateObject("Scripting.FileSystemObject")
set thisfile=fso.opentextfile(whichfile)
my_string=thisfile.readall
if instr(LCase(my_string),"<%")<>0 or instr(LCase(my_string),"<%")<>0 then
Response.Write "<script language='javascript'>alert('上传恶意文件失败');</script>"
muma=1
'if FSO.fileExists(whichfile) then
'FSO.DeleteFile(whichfile)
'end if
set fso=nothing
end if
set rs=server.createobject("adodb.recordset")
sql = "select tupian from xinxi where username='"&username&"' and id="&cstr(id)
rs.open sql,conn,1,3
if rs.eof then
response.write "参数错误!"
response.end
else
if muma=1 then
rs("tupian")=0
rs.update
response.write "图片上传失败!"
else
rs("tupian")=filename
rs.update
response.write "图片成功上传!"
end if
end if
rs.close
set rs=nothing
closedb
response.write "<meta http-equiv=refresh content=""1;URL=user_xxgl.asp"">"
%><br>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -