<!--#include file="conn.asp" -->
<!--#include FILE="upload_5xsoft.inc"-->
<%
response.Buffer
if session("user_name")="" or session ("id")="" then
response.write "<script language=JavaScript>" & chr(13) & "alert('对不起,你无权查看此页!');" & "window.location.href = 'ht_dl.asp'"&" </script>"
end if
if request("title")="" or request("name")="" or request("news")="" then
response.write "<script language=JavaScript>" & chr(13) & "alert('请确认信息已经填写完整!');" & "history.back()" & "</script>"
Response.End
end if
function MakedownName()
dim fname
fname = now()
fname = replace(fname,"-","")
fname = replace(fname," ","")
fname = replace(fname,":","")
fname = replace(fname,"PM","")
fname = replace(fname,"AM","")
fname = replace(fname,"上午","")
fname = replace(fname,"下午","")
fname = int(fname) + int((10-1+1)*Rnd + 1)
MakedownName=fname
end function
dim upload,file,formName,formPath,fileformat
set upload=new upload_5xsoft
upload.form("img")
formPath="file/"
for each formName in upload.file ''列出所有上传了的文件
set file=upload.file(formName) ''生成一个文件对象
if file.FileSize>0 then ''如果 FileSize > 0 说明有文件数据
fileformat=mid(file.FileName,InStrRev(file.FileName, ".")+1)
if fileformat<>"gif" or fileformat<>"jpg" or fileformat<>"bmp" then
response.write "<Script language=javascript>" & chr(13) & "alert('您上传的文件是不符合格式的的文件!\n支持上传的文件格式有:*.gif、*.jpg、*.bmp');" & "history.back()" & "</Script>"
response.end
end if
if file.FileSize>310000 then
response.write "<Script language=javascript>" & chr(13) & "alert('您上传的文件超过了指定大小!\n请上传小于300K的文件');" & "history.back()" & "</Script>"
response.end
end if
newname=MakedownName() & "." & mid(file.FileName,InStrRev(file.FileName, ".")+1)
file.SaveAs Server.mappath(formPath & newname) ''保存文件
else
response.write "未找到文件 <A HREF=javascript:history.back(1)>返回</A>"
response.end
end if
next
sql="insert into p_news(title,name,news,content,url,time,user_name) values('" & request("title") & "','" & request("name") & "','" & request("news") & "','" & request("content") & "','" & formPath & newname & "','" & now() & "','" & session("user_name") & "')"
conn.execute sql
response.write "<script language=JavaScript>" & chr(13) & "alert('上传成功!');" & "history.back()" & "</script>"
%>
<!--#include file="conn.asp" -->
<!--#include FILE="upload_5xsoft.inc"-->
<%
response.Buffer
if session("user_name")="" or session ("id")="" then
response.write "<script language=JavaScript>" & chr(13) & "alert('对不起,你无权查看此页!');" & "window.location.href = 'ht_dl.asp'"&" </script>"
end if
if request("title")="" or request("name")="" or request("news")="" then
response.write "<script language=JavaScript>" & chr(13) & "alert('请确认信息已经填写完整!');" & "history.back()" & "</script>"
Response.End
end if
function MakedownName()
dim fname
fname = now()
fname = replace(fname,"-","")
fname = replace(fname," ","")
fname = replace(fname,":","")
fname = replace(fname,"PM","")
fname = replace(fname,"AM","")
fname = replace(fname,"上午","")
fname = replace(fname,"下午","")
fname = int(fname) + int((10-1+1)*Rnd + 1)
MakedownName=fname
end function
dim upload,file,formName,formPath,fileformat
set upload=new upload_5xsoft
upload.form("img")
formPath="file/"
for each formName in upload.file ''列出所有上传了的文件
set file=upload.file(formName) ''生成一个文件对象
if file.FileSize>0 then ''如果 FileSize > 0 说明有文件数据
fileformat=mid(file.FileName,InStrRev(file.FileName, ".")+1)
if fileformat<>"gif" or fileformat<>"jpg" or fileformat<>"bmp" then
response.write "<Script language=javascript>" & chr(13) & "alert('您上传的文件是不符合格式的的文件!\n支持上传的文件格式有:*.gif、*.jpg、*.bmp');" & "history.back()" & "</Script>"
response.end
end if
if file.FileSize>310000 then
response.write "<Script language=javascript>" & chr(13) & "alert('您上传的文件超过了指定大小!\n请上传小于300K的文件');" & "history.back()" & "</Script>"
response.end
end if
newname=MakedownName() & "." & mid(file.FileName,InStrRev(file.FileName, ".")+1)
file.SaveAs Server.mappath(formPath & newname) ''保存文件
else
response.write "未找到文件 <A HREF=javascript:history.back(1)>返回</A>"
response.end
end if
next
sql="insert into p_news(title,name,news,content,url,time,user_name) values('" & request("title") & "','" & request("name") & "','" & request("news") & "','" & request("content") & "','" & formPath & newname & "','" & now() & "','" & session("user_name") & "')"
conn.execute sql
response.write "<script language=JavaScript>" & chr(13) & "alert('上传成功!');" & "history.back()" & "</script>"
%>