📄 uploadpic_ok.asp
字号:
<!--#include file="mdb/conn.asp" -->
<!--#include file="config.asp" -->
<!--#include file="check.asp" -->
<!--#include file="upload.inc"-->
<%'on error resume next%>
<%
dim upload,file,formName,formPath,iCount,filename,fileExt,i
set upload=new upload_5xSoft '建立上传对象
name=upload.form("name")
zhuanti=upload.form("zhuanti")
formPath=upload.form("filepath")
'photointro=replace(upload.form("photointro"),">",">")
'photointro=replace(photointro,"<","<")
'photointro=replace(photointro,"'","’")
photointro=HTMLEncode2(upload.form("photointro"))
'在目录后加(/)
if right(formPath,1)<>"/" then formPath=formPath&"/"
iCount=0
for each formName in upload.file '列出所有上传了的文件
set file=upload.file(formName) '生成一个文件对象
if file.filesize<0 then
response.redirect "error.asp?errid=4"
response.end
end if
if file.filesize>2000000 then
response.redirect "error.asp?errid=6"
response.end
end if
fileExt=lcase(right(file.filename,4))
if fileEXT<>".gif" and fileEXT<>".jpg" and fileEXT<>".png" then
response.redirect "error.asp?errid=7"
response.end
end if
filenamett=file.FileName
filenamet=year(now)&month(now)&day(now)&hour(now)&minute(now)&second(now)&fileExt
filename=formPath&filenamet
filesize=file.filesize
if file.FileSize>0 then '如果 FileSize > 0 说明有文件数据
file.SaveAs Server.mappath(filename) '保存文件
iCount=iCount+1
end if
set file=nothing
FilePath=Server.MapPath(".")
FilePath=FilePath & "\paladin\"
Set Jpeg = Server.CreateObject("Persits.Jpeg")
Jpeg.Open (FilePath & filenamet)
'开始变更所有文件扩展名为jpg
filenamelen=len(filenamet)
filenamelen=filenamelen-4
filenamet1=filenamet
filenamet=left(filenamet,filenamelen)
filenamet=filenamet&".jpg"
'结束文件名变更
'开始判断哪边为长边,以长边进行缩放
imgWidth=Jpeg.OriginalWidth
imgHeight=Jpeg.OriginalHeight
if imgWidth>=imgHeight and imgWidth>120 then
Jpeg.Width=150
Jpeg.Height=Jpeg.OriginalHeight/(Jpeg.OriginalWidth/150)
end if
if imgHeight>imgWidth and imgHeight>113 then
Jpeg.Height=113
Jpeg.Width=Jpeg.OriginalWidth/(Jpeg.OriginalHeight/113)
end if
'结束判断
'ImgObj.SaveFile(FilePath & "small_" & filenamet)
'end if
'ImgObj.Free
'Set ImgObj = nothing
Jpeg.Sharpen 1, 130
Jpeg.Save (FilePath & "small_" & filenamet)
'写入数据库
yy=year(date)
mm=right("00"&month(date),2)
dd=right("00"&day(date),2)
idate=yy & "-" & mm & "-" & dd & " "
xx=right("00"&hour(time),2)
ff=right("00"&minute(time),2)
mm=right("00"&second(time),2)
itime=xx & ":" & ff & ":" & mm
itime=idate&itime
photourlb=formPath & filenamet1
'if imgwidth<320 and imgheight<240 then
photourls=formPath & "small_" & filenamet
'else
'photourls=photourlb
'end if
'response.write "照片数据库文件目录:" & formpath & "<br>"
'response.write "照片说明:" & photointro & "<br>"
'response.write "照片名字:" & name & "<br>"
'response.write "照片分类:" & typeid & "<br>"
'response.write "照片时间:" & itime & "<br>"
'response.write "照片大小:" & filesize & "<br>"
'response.write "照片尺寸:" & imgheight &"<br>"
'response.write "照片尺寸:" & imgwidth &"<br>"
'response.write "照片路径:" & photourlb &"<br>"
'response.end
strSQL= "insert into desktop ([name],zhuanti,jj,[time],imgh,imgw,filesize,url,surl) values ('"&name&"','"&zhuanti&"','"&photointro&"','"&itime&"','"&imgheight&"','"&imgwidth&"','"&filesize&"','"&photourlb&"','"&photourls&"')"
'response.write strSQL
'response.end
conn.execute strSQL
'结束数据库写入
'response.write "<br>文件上传完毕<br>"
next
set upload=nothing '删除对象
response.write "<SCRIPT language=JavaScript>alert('文件上传成功,返回!');"
response.write "this.location.href='addfile.asp?typeid="&zhuanti&"';</SCRIPT>"
'url="addfile.asp"
'response.redirect url
function HTMLEncode2(fString)
fString = Replace(fString, CHR(13), "")
fString = Replace(fString, CHR(10) & CHR(10), "</P><P>")
fString = Replace(fString, CHR(10), "<BR>")
HTMLEncode2 = fString
end function
%>
<!--本系统由爬树的朱朱制作--->
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -