日期:2014-05-16 浏览次数:20869 次
<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<!--#include file="conn.asp"-->
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>无标题文档</title>
</head>
<body>
<%
On Error Resume Next
Dim Upload,upfile
Set Upload=Server.CreateObject("Persits.Upload")
Upload.SetMaxSize 5*1024*1024,True
Upload.Save
If err.Number=8 Then
Response.Write("<script language='JavaScript'>alert('上传文件超过5MB,请重新上传!');history.back();</script>")
Response.End()
End If
Set upfile=Upload.Files("upfile")
upfile.SaveAs Server.MapPath("upload")&"\"&GetFileName(now())&upfile.Ext
'把文件的相关信息传到数据库当中去
Dim sqlstr
sqlstr="Insert into tb_upfile_folder(file_name,file_size,file_ext,file_intro) values('"&upfile.Filename&"','"&upfile.Size&"','"&upfile.Ext&"','"&Upload.Form("txt_intro").value&"')"
conn.Execute(sqlstr)
Response.Write("<script language='JavaScript'>alert('上传文件到服务器成功!');window.close();window.opener.location.reload();</script>")
Response.End()
'dDate=now() 2012 07 01 13 06 47.JPG
'---------- 根据时间获取的字符串 -----------
Function GetFileName(dDate)
GetFileName = RIGHT("0000"+Trim(Year(dDate)),4)+RIGHT("00"+Trim(Month(dDate)),2)+RIGHT("00"+Trim(Day(dDate)),2)+RIGHT("00" + Trim(Hour(dDate)),2)+RIGHT("00"+Trim(Minute(dDate)),2)+RIGHT("00"+Trim(Second(dDate)),2)
End Function
%>
</body>
</html>