?? uploadpic_ok.asp
字號(hào):
<!--#include file="checkthis.asp" -->
<!--#include file="data/conn.asp" -->
<!--#include file="upload.inc"-->
<%'on error resume next%>
<%
dim upload,file,formName,formPath,iCount,filename,fileExt,i
set upload=new upload_5xSoft '建立上傳對(duì)象
name=upload.form("name")
zhuanti=upload.form("zhuanti")
formPath=upload.form("filepath")
photointro=HTMLEncode2(upload.form("photointro"))
if right(formPath,1)<>"/" then formPath=formPath&"/"
for each formName in upload.file '列出所有上傳了的文件
set file=upload.file(formName) '生成一個(gè)文件對(duì)象
if file.filesize<0 then
response.redirect "info.asp?info=請(qǐng)選擇上傳的文件"
response.end
end if
if file.filesize>2000000 then
response.redirect "info.asp?info=文件不得超過(guò)2M"
response.end
end if
fileExt=lcase(right(file.filename,4))
if fileEXT<>".gif" and fileEXT<>".jpg" and fileEXT<>".png" and fileEXT<>".bmp" then
response.redirect "info.asp?info=只允許上傳gif,jPG,png,bmp文件!"
response.end
end if
Dim Jpeg
FilePath=Server.MapPath("./")'設(shè)置上傳目錄位置
FilePath=FilePath &"/"&formPath
response.write FilePath
Set Jpeg = Server.CreateObject("Persits.Jpeg")
If -2147221005=Err then
Response.write "info.asp?info=沒(méi)有ASPJPEG組件請(qǐng)安裝!"
Response.End()
End If
ranNum=int(900*rnd)+100
filenamett=file.FileName
filenamet=year(now)&month(now)&day(now)&hour(now)&minute(now)&second(now)&ranNum&fileExt
filename=filepath&filenamet
filesize=file.filesize
if file.FileSize>0 then '如果 FileSize > 0 說(shuō)明有文件數(shù)據(jù)
file.SaveAs filename '保存文件
else
response.redirect "info.asp?info=文件錯(cuò)誤!"
response.end
end if
Jpeg.Open filename
Jpeg.Canvas.Font.Color = &HA83C3C
Jpeg.Canvas.Font.Family = "宋體" 'family設(shè)置字體
Jpeg.Canvas.Font.Bold = false '是否設(shè)置成粗體
Jpeg.Canvas.Font.Size = 12 '字體大小
Jpeg.Canvas.Font.Quality = 5'輸出質(zhì)量
Jpeg.Canvas.Print Jpeg.width-104, Jpeg.height-13, "www.2st.name"
Jpeg.Save filename
set file=nothing
Jpeg.Open (filename)
'開(kāi)始變更所有文件擴(kuò)展名為jpg
filenamelen=len(filenamet)
filenamelen=filenamelen-4
filenamet1=filenamet
filenamet=left(filenamet,filenamelen)
filenamet=filenamet&".jpg"
'結(jié)束文件名變更
'開(kāi)始判斷哪邊為長(zhǎng)邊,以長(zhǎng)邊進(jìn)行縮放
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
response.write "1"
'結(jié)束判斷
'ImgObj.SaveFile(FilePath & "small_" & filenamet)
'end if
'ImgObj.Free
'Set ImgObj = nothing
Jpeg.Sharpen 1, 130
Jpeg.Save (FilePath & "small_" & filenamet)
'寫(xiě)入數(shù)據(jù)庫(kù)
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
strSQL= "insert into desktop ([name],zhuanti,jj,[time],imgh,imgw,filesize,url,surl) values ('"&name&"','"&zhuanti&"','"&photointro&"','"&itime&"','"&imgheight&"','"&imgwidth&"','"&filesize&"','"&photourlb&"','"&photourls&"')"
conn.execute strSQL
response.write 'ok'
next
set upload=nothing
response.write "<SCRIPT language=JavaScript>alert('文件上傳成功,返回!');"
response.write "this.location.href='addfile.asp?typeid="&zhuanti&"';</SCRIPT>"
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
%>
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -