photoupload.asp
来自「用JAVA编写的网络留言簿。前台功能 一、用户注册/注册资料修改。 二、」· ASP 代码 · 共 65 行
ASP
65 行
<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<!--#include file="session.asp" -->
<!--#include file="conn.asp" -->
<!--#include file="upload_5xsoft.inc" -->
<%
if session("photoflag")<>"1" then
response.write"<script>alert('对不起,您没能通过管理员的认证,无权上传照片!');location='photo.asp'</script>"
response.end
end if
set upload=new upload_5xsoft
phototitle=replace(trim(upload.Form("phototitle")),"'","")
photocomment=replace(trim(upload.Form("photocomment")),"'","")
set file=upload.file("photo")
fileExt=lcase(right(file.filename,4))
if fileEXT<>".gif" and fileEXT<>".jpg" then
response.write"<script>alert('文件格式不对,请重新上传!');location='"&request.ServerVariables("HTTP_REFERER")&"'</script>"
response.end
end if
if file.fileSize>0 then
formPath="photo"
''在目录后加(/)
if right(formPath,1)<>"/" then
formPath=formPath&"/"
end if
set rs=server.CreateObject("adodb.recordset")
rs.open "photo",conn,3,3
rs.addnew
vfname = makefilename(now())
fname = vfname & "." & GetExtendName(file.FileName)
file.SaveAs Server.mappath(formPath&fname) ''保存文件
rs("photouser")=session("username")
rs("phototitle")=phototitle
rs("photocomment")=photocomment
rs("photoname")=fname
rs("phototime")=now()
rs.update
response.write "<script>alert('照片上传成功!');location='photo.asp'</script>"
end if
set file=nothing
set upload=nothing
function makefilename(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,"下午","")
makefilename=fname
end function
function GetExtendName(FileName)
dim ExtName
ExtName = LCase(FileName)
ExtName = right(ExtName,3)
ExtName = right(ExtName,3-Instr(ExtName,"."))
GetExtendName = ExtName
end function
%>
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?