⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 uploadpic_ok.asp

📁 以朱朱相册为程序原型整合开发winds相册
💻 ASP
字号:
<!--#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 '建立上传对象

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)  '生成一个文件对象
   
    if file.filesize<0 then
        response.redirect "info.asp?info=请选择上传的文件"
        response.end
    end if   
    if file.filesize>2000000 then
        response.redirect "info.asp?info=文件不得超过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("./")'设置上传目录位置
   FilePath=FilePath &"/"&formPath

   response.write FilePath

    Set Jpeg = Server.CreateObject("Persits.Jpeg")
If -2147221005=Err then 
Response.write "info.asp?info=没有ASPJPEG组件请安装!" 
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 说明有文件数据
        file.SaveAs filename   '保存文件
        else
    response.redirect "info.asp?info=文件错误!"
    response.end
    end if
Jpeg.Open filename
Jpeg.Canvas.Font.Color = &HA83C3C
Jpeg.Canvas.Font.Family = "宋体" 'family设置字体
Jpeg.Canvas.Font.Bold = false  '是否设置成粗体
Jpeg.Canvas.Font.Size = 12 '字体大小
Jpeg.Canvas.Font.Quality = 5'输出质量 
Jpeg.Canvas.Print Jpeg.width-104, Jpeg.height-13, "www.2st.name"
Jpeg.Save filename
    set file=nothing
    Jpeg.Open (filename)
    '开始变更所有文件扩展名为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

	response.write "1"
    '结束判断

    '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
	
	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
%>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -