日期:2010-06-21  浏览次数:21285 次

<!--#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
'--------------------------------------------------------