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

<!--#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
lq7350684
Rank: 6Rank: 6
等 级:贵宾
威 望:20
帖 子:5089
专家分:98
注 册:2006-11-6
收藏
得分:0 
报的什么错啊?
2007-03-09 14:48
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
阳光白雪
Rank: 7Rank: 7Rank: 7
等 级:贵宾
威 望:39
帖 子:2220
专家分:0
注 册:2005-11-18
收藏
得分:0 
dim upload,file,formName,formPath,fileformat
set upload=new upload_5xsoft
upload.form("img") ''这句什么意思,应该是:变量 = upload.form("img") 吧?
formPath="file/"

专注于WEB前端交互平台开发:[url=http://blog./]blog.[/url](富客户端技术(RIA)交流平台)
2007-03-09 15:06
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
阳光白雪
Rank: 7Rank: 7Rank: 7
等 级:贵宾
威 望:39
帖 子:2220
专家分:0
注 册:2005-11-18
收藏
得分:0 
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

此处应该为“逻辑与”关系,为“逻辑或”永远都传不上去

专注于WEB前端交互平台开发:[url=http://blog./]blog.[/url](富客户端技术(RIA)交流平台)
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
快速回复:我做的图片新闻上传页面,麻烦帮我看看哪错了
数据加载中...
 
   



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

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