我这里图片上传后怎么才能让图片的路径自动保存到数据库??

来源:互联网 发布:淘宝客服绩效考核表格 编辑:程序博客网 时间:2024/04/29 21:58
各位高手,麻烦看看我这代码要改那里才能让图片的地址自动保存在我的数据库中?
这个无惧上传页面
upfile_flash.asp
<!--#include file="upload_wj.inc"-->
<%
set upload=new upload_file
if upload.form("act")="uploadfile" then
formpath="up_pic/"
FileExt=trim(upload.form("FileExt"))

i=0
for each formName in upload.File
set file=upload.File(formName)
 
 fileExt=lcase(file.FileExt)'得到的文件扩展名不含有.
 if file.filesize<100 then
response.write "<script language=javascript>alert('请先选择你要上传的文件!');history.go(-1);</script>"
response.end
 end if
 if FileExt<>"swf" and FileExt<>"jpg"  and fileext<>"gif" then 
response.write "<script language=javascript>alert('该文件类型不能上传!');history.go(-1);</script>"
response.end
 end if
 if FileExt="swf" then
if fileext<>"swf"  then
response.write "<script language=javascript>alert('只能上传swf格式的Flash文件!');history.go(-1);</script>"
response.end
end if
 end if
 if FileExt="jpg" then
if FileExt<>"gif" and fileext<>"jpg"  then
response.write "<script language=javascript>alert('只能上传jpg或gif格式的图片!');history.go(-1);</script>"
response.end
     end if
 end if
 if FileExt="swf" then
if file.filesize>(3000*1024) then
response.write "<script language=javascript>alert('Flash文件大小不能超过3m!');history.go(-1);</script>"
response.end
end if
 end if
 if FileExt="jpg" then
if file.filesize>(1000*1024) then
response.write "<script language=javascript>alert('图片文件大小不能超过1m!');history.go(-1);</script>"
response.end
end if
 end if

 randomize
 ranNum=int(90000*rnd)+10000
 filename=formPath&year(now)&month(now)&day(now)&hour(now)&minute(now)&second(now)&ranNum&"."&fileExt
session("bb")=filename%>
<form id="form1" name="form1" method="post" action="save.asp">
  <table width="373" border="1">
    <tr>
      <td width="92">图片地址</td>
      <td width="265">图片名称</td>
    </tr>
    <tr>
      <td><input name="url" type="text" id="url" value="<% response.write FileName%>" /></td>
    </tr>
  </table>
  <input type="submit" name="Submit" value="提交" />
</form>

<%
 if file.FileSize>0 then         ''如果 FileSize > 0 说明有文件数据
  'file.SaveAs Server.mappath(filename)   ''保存文件
  file.SaveToFile Server.mappath(FileName)
session("aa")=FileName
  if filelx="swf" then
  response.write "<script>window.opener.document."&upload.form("FormName")&".size.value='"&int(file.FileSize/1024)&" K'</script>"
  end if
  response.write "<script>window.opener.document."&upload.form("FormName")&"."&upload.form("EditName")&".value='"&FileName&"'</script>"
session("aa")=FileName%>
<%
end if
set file=nothing
next
set upload=nothing
end if
%>

我这个<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>保存图片</title>
</head>
我这个[color=#99CC00]save.asp页面怎么才能融合到上面的upfile_flash.asp页面完成自动保存功能????[/color]<!--#include file="conn.asp"-->
<%set rs=server.createobject("adodb.recordset")
rs.open "select * from url" ,conn,1,3
rs.addnew 
rs("url")=request("url")
rs.update
%>
<img src="<% response.write request("url")%>"></img>
<script language="javascript">
window.alert("文件上传成功!");
window.close();
</script>

<body>
</body>
</html>

0 0
原创粉丝点击