| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 796 人关注过本帖
标题:我做的图片新闻上传页面,麻烦帮我看看哪错了
取消只看楼主 加入收藏
dh2007
Rank: 1
等 级:新手上路
帖 子:228
专家分:0
注 册:2007-2-28
结帖率:0
收藏
 问题点数:0 回复次数:7 
我做的图片新闻上传页面,麻烦帮我看看哪错了

<!--#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 "未找到文件 &nbsp;&nbsp;<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 "未找到文件 &nbsp;&nbsp;<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>"
%>

搜索更多相关主题的帖子: 页面 麻烦 
2007-03-09 14:32
dh2007
Rank: 1
等 级:新手上路
帖 子:228
专家分:0
注 册:2007-2-28
收藏
得分:0 
先他直接运行
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

后来我把这段去掉后报

错误'800a01c2'
错误的参数个数或无效的参数属性值:'file'

2007-03-09 15:01
dh2007
Rank: 1
等 级:新手上路
帖 子:228
专家分:0
注 册:2007-2-28
收藏
得分:0 

晕,怎么复制上去了2次,不好意思
对了
先浏览器直接触动了
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
这个条件语句

但我的表单是提交了内容过去的


2007-03-09 15:09
dh2007
Rank: 1
等 级:新手上路
帖 子:228
专家分:0
注 册:2007-2-28
收藏
得分:0 
以下是引用阳光白雪在2007-3-9 13:01:49的发言:
''创建上传对象
Set Upload = new upload_file

' '接收字符数据
Upload.Form("表单元素名")

''遍历表单中的文件域,接收文件(二进制)数据
For Each FormObjName In Upload.File
Set File = Upload.File(FormObjName)
...
Nxet

我刚才提问,他告诉我的

2007-03-09 15:11
dh2007
Rank: 1
等 级:新手上路
帖 子:228
专家分:0
注 册:2007-2-28
收藏
得分:0 
哦,但是在这段上面都有错误啊

2007-03-09 15:12
dh2007
Rank: 1
等 级:新手上路
帖 子:228
专家分:0
注 册:2007-2-28
收藏
得分:0 
难到就没有人来帮帮我了吗????

2007-03-09 15:22
dh2007
Rank: 1
等 级:新手上路
帖 子:228
专家分:0
注 册:2007-2-28
收藏
得分:0 

谁来帮帮我啊!


2007-03-09 16:18
dh2007
Rank: 1
等 级:新手上路
帖 子:228
专家分:0
注 册:2007-2-28
收藏
得分:0 
"止痒不求人"
自己解决了
- -

2007-03-09 16:50
快速回复:我做的图片新闻上传页面,麻烦帮我看看哪错了
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.029750 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved