关于上传图片的问题

snolidge 2003-09-18 07:35:30
无组件上传
我想实现这样的功能
在一个form里
除了上传图片的input file框外,还有一些基本信息,比如介绍等。怎样上传到文件家??其他信息保存到数据库??

我试着改一个程序,可其他信息就不能添加到数据库了
...全文
22 11 打赏 收藏 转发到动态 举报
写回复
用AI写文章
11 条回复
切换为时间正序
请发表友善的回复…
发表回复
snolidge 2003-09-26
  • 打赏
  • 举报
回复
我已经搞定了
snolidge 2003-09-18
  • 打赏
  • 举报
回复
谢!!我试一下,明天给结果
楚人无衣 2003-09-18
  • 打赏
  • 举报
回复
4.取文件扩展名凼数:
function getextendname(filename)
extname=lcase(filename)
extname=right(extname,3)
extname=right(extname,3-instr(extname,"."))
getextendname=extname
end function
楚人无衣 2003-09-18
  • 打赏
  • 举报
回复

3.表单相关部分:
1.名称:<input type="text" name="s01name" size="10" onMouseOver = "this.style.backgroundColor = '#E5F0FF'" onMouseOut = "this.style.backgroundColor = ''" style="position: relative; height: 20; color: #0000FF; border-left-style: solid; border-left-width: 0; border-right-style: solid; border-right-width: 0; border-top: 0 inset #000099; border-bottom-style: inset; border-bottom-color: #000099">
价格:<input type="text" name="s01price" size="3" onMouseOver = "this.style.backgroundColor = '#E5F0FF'" onMouseOut = "this.style.backgroundColor = ''" style="position: relative; height: 20; color: #0000FF; border-left-style: solid; border-left-width: 0; border-right-style: solid; border-right-width: 0; border-top-style: solid; border-top-width: 0; border-bottom-style: inset; border-bottom-color: #000099; padding-top: 0">元 
图片:<input type="file" name="s01img" size="12" onMouseOver = "this.style.backgroundColor = '#E5F0FF'" onMouseOut = "this.style.backgroundColor = ''" style="position: relative; height: 20; color: #0000FF; border-left-style: solid; border-left-width: 0; border-right-style: solid; border-right-width: 0; border-top: 0 inset #000099; border-bottom-style: inset; border-bottom-color: #000099"><br>
  类别:<select size="1" name="s01sort" onMouseOver = "this.style.backgroundColor = '#E5F0FF'" onMouseOut = "this.style.backgroundColor = ''" style="color: #0000FF">
<%if not rss.eof then%>
<option selected value="<%=rss("id")%>"><%=rss("name")%></option>
 
<%
if s01sort="" then
session("name")=rss("name")
end if
for i=0 to rss.recordcount-1
if rss("name")<>session("name") then
%>
<option value="<%=rss("id")%>"><%=rss("name")%></option>
<%
end if
rss.movenext
next
rss.movefirst
end if
%>
 
</select> </font><font color="#FF00FF">折扣率:</font><font color="#000099">会员:<input type="text" name="s01sre" size="3" onMouseOver = "this.style.backgroundColor = '#E5F0FF'" onMouseOut = "this.style.backgroundColor = ''" style="position: relative; height: 20; color: #0000FF; border-left-style: solid; border-left-width: 0; border-right-style: solid; border-right-width: 0; border-top-style: solid; border-top-width: 0; border-bottom-style: inset; border-bottom-color: #000099; padding-top: 0" value="0.9"> 
网吧联盟:<input type="text" name="s01bre" size="3" onMouseOver = "this.style.backgroundColor = '#E5F0FF'" onMouseOut = "this.style.backgroundColor = ''" style="position: relative; height: 20; color: #0000FF; border-left-style: solid; border-left-width: 0; border-right-style: solid; border-right-width: 0; border-top-style: solid; border-top-width: 0; border-bottom-style: inset; border-bottom-color: #000099; padding-top: 0" value="0.85"> 
分销商:<input type="text" name="s01cre" size="3" onMouseOver = "this.style.backgroundColor = '#E5F0FF'" onMouseOut = "this.style.backgroundColor = ''" style="position: relative; height: 20; color: #0000FF; border-left-style: solid; border-left-width: 0; border-right-style: solid; border-right-width: 0; border-top-style: solid; border-top-width: 0; border-bottom-style: inset; border-bottom-color: #000099; padding-top: 0" value="0.8"> <br>
  简介:<textarea rows="1" name="s01des" cols="48" onMouseOver = "this.style.backgroundColor = '#E5F0FF'" onMouseOut = "this.style.backgroundColor = ''" style="color: #0000FF"></textarea><br>
  使用:<textarea rows="1" name="s01use" cols="48" onMouseOver = "this.style.backgroundColor = '#E5F0FF'" onMouseOut = "this.style.backgroundColor = ''" style="color: #0000FF"></textarea><br>
  开发商网址:<input type="text" name="s01f" size="45" onMouseOver = "this.style.backgroundColor = '#E5F0FF'" onMouseOut = "this.style.backgroundColor = ''" style="position: relative; height: 20; color: #0000FF; border-left-style: solid; border-left-width: 0; border-right-style: solid; border-right-width: 0; border-top-style: solid; border-top-width: 0; border-bottom-style: inset; border-bottom-color: #000099; padding-top: 0" value="http://">
楚人无衣 2003-09-18
  • 打赏
  • 举报
回复
给你一些代码片段,希望有点帮助:
无组件上传5xSoft类,以下代码从程序中截取,冗余之处请多谅解,请研究其中之理

1.上传图片:
set upload=new upload_5xSoft '用此类,则表单提交按钮必须指定一个名字,不然会出现错误;还有,不能进行数值比较
set fs=server.createobject("scripting.filesystemobject")

set file01=upload.file("s01img")
if file01.filesize>0 and file01.filename<>"" then
if fs.fileexists(server.mappath("../stores/images/"&file01.filename)) then
response.write "<script language='javascript'> alert('上传失败,此文件名已存在!'); </script>"
else
if instr(".gif.jpg.bmp",getextendname(file01.filename))>0 then
if file01.filesize<20480 then
file01.saveas server.mappath("../stores/images/"&file01.filename)
else
response.write "<script language='javascript'> alert('上传失败,大小超过了20K!'); </script>"
end if
else
response.write "<script language='javascript'> alert('上传失败,其不为图片格式!'); </script>"
end if
end if
end if

2.数据入库:
if upload.form("s01name")<>"" and upload.form("s01price")<>"" then
set rs=conn.execute("select * from stores where name='"&upload.form("s01name")&"'and price="&upload.form("s01price")&" and sort="&upload.form("s01sort")&"")
if not rs.eof then
response.write "<script language=javascript> alert('该商品已存在!') </script>"
else
conn.execute("insert into stores(sort,name,price,sprice,bprice,cprice,img,des,huse,sfrom)" & _
" values("&upload.form("s01sort")&",'"&upload.form("s01name")&"',"&upload.form("s01price")&","&upload.form("s01price")*upload.form("s01sre")&","&upload.form("s01price")*upload.form("s01bre")&","&upload.form("s01price")*upload.form("s01cre")&",'"&file01.filename&"','"&server.htmlencode(upload.form("s01des"))&"','"&server.htmlencode(upload.form("s01use"))&"','"&server.htmlencode(upload.form("s01f"))&"')")
end if
session("store01")=""
set rs=nothing
end if
arcow 2003-09-18
  • 打赏
  • 举报
回复
帮你顶
snolidge 2003-09-18
  • 打赏
  • 举报
回复
这样做谁都会阿,我就是想跟php一样,一起处理了。我以前是些php的
ljupin 2003-09-18
  • 打赏
  • 举报
回复
是不是想点提交按钮后,文件和其他信息一起保存???
这样我没试过,不过应该可以的
如果不是非要一起提交的话,那就在上传旁边加个上传按钮
先传,然后返回文件路经,接着再提交
有空看看动网的注册那页面,就是这么做的!
snolidge 2003-09-18
  • 打赏
  • 举报
回复
如果用无组件上川的,就不能用Request.Form了,我asp不太会,刚开始学。不知道由什么解决办法
luluso 2003-09-18
  • 打赏
  • 举报
回复
up我也在做这方面的。关注。
主要是入库。
  • 打赏
  • 举报
回复
http://access911.net/index.asp?board=4&mode=3&recordid=71FAB51E16DC
http://access911.net/index.asp?board=4&mode=3&recordid=79FAB31E

28,391

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧