ASP无组件上传图片的源代码

2008-02-23 09:41:00来源:互联网 阅读 ()

新老客户大回馈,云服务器低至5折

<!--#include file="upload_5xsoft.inc"-->
<%
Set conn=Server.CreateObject("Adodb.Connection")
connstr="Provider=Microsoft.Jet.OLEDB.4.0;Data Source="& Server.MapPath("db.mdb")
conn.open connstr
'----------------------------------------
function getextendname(filename)
extname=lcase(filename)
extname=right(extname,3)
extname=right(extname,3-instr(extname,"."))
getextendname=extname
end function
'---------------------------------------------------

'-------------------------------------------------------
function filename()
filename=now()
filename=replace(filename,"-","")
filename=replace(filename,":","")
filename=replace(filename," ","")
filename=filename
end function
'----------------------------------------------------------

'-------------------------------------------------------------------
set upload=new upload_5xsoft

set upfile=upload.file("files")
title=upload.form("t1")
info=upload.form("t2")

if upfile.filesize>0 and upfile.filename<>"" then
if instr("jpg,bmp,gif",getextendname(upfile.filename))>0 then
if upfile.filesize<204800 then
fname=filename&"."&getextendname(upfile.filename)
upfile.saveas server.mappath("pic/"&fname)

sql="insert into img (title,info,imgpath)values('" title "','" info "','" fname "')"
conn.Execute sql
conn.close
response.write "<script>alert('添加图片成功!');top.location.href='index.asp';</script>"
else
response.write "<script language='javascript'> alert('文件上传失败,大小超过了200K!');history.back(); </script>"
end if
else
response.write "<script language='javascript'> alert('文件上传失败,其不为图片格式!');history.back(); </script>"
end if
end if
'--------------------------------------------------------

标签:

版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com
特别注意:本站所有转载文章言论不代表本站观点,本站所提供的摄影照片,插画,设计作品,如需使用,请与原作者联系,版权归原作者所有

上一篇:关于页面的客户端翻页功能的实现

下一篇:ASP中数据库调用中常见错误的现象和解决