📄 photo_pe.asp
字号:
<!--插入html头部分以及数据库接口-->
<!--#include file="in_conn.asp"-->
<!--获取照片限制大小-->
<!--#include file="in_phsize.asp"-->
<!--时间转化ID的函数-->
<!--#include file="in_idtime.asp"-->
<%
Server.ScriptTimeOut=5000
%>
<body>
<!--插入网站置顶-->
<% if u_name="" then
Response.Redirect "log_err.asp"
else
%>
<!--#include file="in_topmb.asp"-->
<% end if %>
<%
'判断用户权限
IF u_power=0 THEN
Response.Redirect "resp.asp?cmd=id_wait"
ELSEIF u_power<0 THEN
Response.Redirect "resp.asp?cmd=id_forbid&time="&u_fobdate
END IF
%>
<%
Dim UploadFilePath,UploadLimitSize,UploadfileAllowext
UploadFilePath = "img/photo/"
'文件上传路径
UploadLimitSize = DEF_phsize*1024
'最大上传文件大小,单位为K
UploadfileAllowext = "jpg/gif"
'可以上传的文件类型
function CanUp(Fileurl)
if InStr(1,UploadfileAllowext,Fileurl,1)=0 OR InStr(1,UploadfileAllowext,Fileurl,1)=null Then
CanUp=False
else
CanUp=True
end if
end function
'建立上传对象
dim vtip,vpurl,NewName
dim vpw,vph
dim vdate
dim vphidfre
on error resume next
dim savepath
savepath=Server.MapPath(UploadFilePath)
dim Upload
Set Upload=Server.CreateObject("Persits.Upload")
Upload.SetMaxSize UploadLimitSize,True
Upload.OverwriteFiles = false
Count=Upload.Save(savepath)
'获得表单传值
vtip=trim(Upload.Form("txttip"))
vdate=now()
vphidfre=idtime(vdate)
flagerr=0
if Count<1 then
flagerr=1
end if
If Err.Number=8 Then
flagerr=2
ElseIF Err.Number<>0 Then
flagerr=-1
End If
dim size
For Each File in Upload.Files
strShortFileName=File.filename '取得文件名
strExtension=Mid(strShortFileName, InStrRev(strShortFileName, ".")+1) '取得扩展名
'检查正确性
if strShortFileName="" OR InStrRev(strShortFileName, ".")=0 OR InStrRev(strShortFileName, ".")=Null then
File.Delete
flagerr=1
elseif CanUp(strExtension)=False then
File.Delete
flagerr=3
else
vvvsize=file.size
'获取图片的宽和高
vpw=File.ImageWidth
vph=File.ImageHeight
'产生随即数
randomize
ranNum=int(900*rnd)+100
'这下面两行代码功能为改名,如果不要改名,请去掉
NewName = year(now) & "-" & month(now) & "-" & day(now) & "-" & hour(now) & "-" & minute(now) & "-" & second(now) &ranNum&"."&LCase(strExtension)
File.Move savepath & "\" & NewName
end if
next
if flagerr=0 then
'如果上传成功
vpurl=UploadFilePath&NewName
'如果图片宽高不符界限,则
if isNumeric(vpw) then
If vpw>250 or vph>250 Then
if vpw>vph then
vph=Cint(250 / vpw * vph)
vpw=250
else
vpw=Cint(250 / vph * vpw)
vph=250
end if
End If
else
vpw=250
vph=250
end if
else
'如果上传失败
set Upload=Nothing
dim vcmd
SELECT CASE flagerr
CASE 1
vcmd="img_notfile"
CASE 2
vcmd="img_toobig"
CASE 3
vcmd="img_type"
CASE ELSE
vcmd=""
END SELECT
Response.Redirect "resp.asp?cmd="&vcmd
end if
set Upload=Nothing
'开始插入数据
sqlstr="INSERT INTO tblphoto(p_author,p_tip,p_date,p_url,p_w,p_h,p_belong,p_emo,p_idfre) VALUES('"&u_name&"','"&stryin(vtip)&"',#"&vdate&"#,'"&stryin(vpurl)&"',"&vpw&","&vph&",-1,0,"&vphidfre&")"
conn.Execute sqlstr
%>
<table align="center" width="700" height="50" border="0" cellspacing="0" cellpadding="11" class="rdkuang"><tr>
<td width="100%" height="100%" align="center">
<table align="center" width="400" height="50" border="0" cellspacing="0" cellpadding="0"><tr><td width="100%" height="100%">
<img src="img/jjgo.gif" border="0">
恭喜,上传照片成功!
<br>url:<% =vpurl %><br>
<%
dim vnewphid
vnewphid=conn.Execute("SELECT p_ID FROM tblphoto WHERE p_idfre="&vphidfre,0,1)(0)
%>
<br>请选择接下来的操作:
<br><img src="img/icn_go.gif" border="0" align="absmiddle"><a href="javascript:history.go(-1);">返回并继续上传照片</a>
<br><img src="img/icn_go.gif" border="0" align="absmiddle"><a href="photoview.asp?id=<% =vnewphid %>" target="_blank">打开您刚刚所发布的照片页面</a>
<br><img src="img/icn_go.gif" border="0" align="absmiddle"><a href="phbook.asp">返回到班级相册头页</a>
</td></tr></table>
</td>
</tr></table>
<br>
<!--插入在线统计-->
<!--#include file="in_online.asp"-->
<!--插入网站置底-->
<!--#include file="in_bottom.asp"-->
</body>
</html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -