询问化境ASP上传的路径问题

yangchun1983222 2004-04-23 10:40:19
我想更改这个上传的路径,程序本身是默认上传到根目录下面。但是我想存到一个目录下面专门存放图片。比如image文件夹下面,怎么去更改的。
源代码如下:
<!--#include file="conn.asp"-->
<html><title>example</title>
<body>
<!--#include FILE="upload_5xsoft.inc"-->
<%
set upload=new upload_5xsoft
for each formName in upload.objForm

next
for each formName in upload.objFile
set file=upload.objFile(formName)
if file.FileSize>0 then
file.SaveAs Server.mappath(file.FileName)
sql="select * from news order by id "
set rs=Server.CreateObject("ADODB.recordset")
rs.open sql,conn,1,3
rs.MoveLast
rs("pic")=file.Filename
rs.update
rs.close
conn.close
set rs=nothing
set conn=nothing
response.write"<script>alert('添加图片成功!');history.back();</script>"
end if
set file=nothing
next
set upload=nothing
%>
请求得到高手的帮助!
...全文
60 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
iuhxq 2004-04-24
  • 打赏
  • 举报
回复
<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<!--#include file="upload_5xsoft.inc"-->
<%
'==============================================================================
' 项目名 Project :化境上传扩展
' 文件名 FileName :upfile.asp
' 功能 Function :方便调用,参数把上传结果返回给who,很简单,自己看一下吧
'
' 作者 Author : 小灰
' 联系方式 QQ : 103895
' 联系方式 Email : webmaster@asp2004.net
'
' 创建日期 Date : 2004-4-24
'==============================================================================
On Error Resume Next
action=request.QueryString("action")
if action="save" then
time11=timer()
server.ScriptTimeout=999
dim upload,file,formName,formPath,regEx
Set regEx = New RegExp
regEx.Pattern = "^jpg$|^gif$|^zip$|^rar$"
regEx.IgnoreCase = true
regEx.Global = true
set upload=new upload_5xsoft
if upload.form("filepath")<>"" then
formPath=upload.form("filepath")
if right(formPath,1)<>"/" then formPath=formPath&"/"
Set mypath=Server.CreateObject("Scripting.FileSystemObject")
if mypath.FolderExists(server.MapPath("./")&"\"&formPath)<>true then
mypath.CreateFolder(server.MapPath("./")&"\"&formPath)
end if
for each formName in upload.objFile
set file=upload.file(formName)
temp=split(file.FileName,".")
fileExt=temp(ubound(temp))
if regEx.test(fileExt) then
if upload.form("checkbox")="true" then
randomize
ranNum=int(90000*rnd)+10000
filename=year(now)&month(now)&day(now)&hour(now)&minute(now)&second(now)&ranNum&"."&fileExt
else
filename=file.FileName
end if
if file.FileSize>0 then
file.SaveAs Server.mappath(formPath&filename)
end if
set file=nothing
end if
next
end if
time12=timer()
response.Write("<script language='javascript'>window.opener.document.form1."&upload.form("who")&".value='"&FormatNumber((time12-time11)*1000,1)&"';self.close();</script>")
set upload=nothing
else
%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>文件上传</title>
<style type="text/css">
td{font-size: 9pt}
a:hover{text-decoration: none}
.tx {
border-color:#000000;
border-left-width: 0px;
border-top-width: 0px;
border-right-width: 0px;
border-bottom-width: 1px;
font-size: 9pt;
background-color: #eeeeee;
}
.bt {font-size: 9pt; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; background-color: #eeeeee; cursor: hand}
.tx1 {font-size: 9pt; border: 1px solid; border-color:#000000; color: #000000}
</style>
<script language="JavaScript" type="text/JavaScript">
function exec()
{
waitting.style.visibility="visible";
upload.style.visibility="hidden";
}
</script>
</head>
<body>
<div id=tdcent style='position:relative;left:0;top:0'>
<div id="waitting" style="position:absolute; top:100px; left:240px; z-index:10; visibility:hidden">
<table border="0" cellspacing="1" cellpadding="0" bgcolor="0959AF">
<tr>
<td bgcolor="#FFFFFF" align="center">
<table width="160" border="0" height="50">
<tr>
<td valign="top" class="g1"><div align="center">操 作 执 行 中<br>请稍候... </div></td>
</tr>
</table>
</td>
</tr>
</table>
</div>
</div>
<div id="upload" style="visibility:visible">
<form name="form1" method="post" action="upfile.asp?action=save" enctype="multipart/form-data" >
<table border="1" cellspacing="0" cellpadding="0" bordercolorlight="#000000" bordercolordark="#CCCCCC">
<tr>
<td align="left" valign="middle"> </td>
<td bgcolor="#CCCCCC" align="left" valign="middle">文件上传</td>
</tr>
</table>
<table width="70%" border="1" cellspacing="0" cellpadding="5" align="center" bordercolordark="#CCCCCC" bordercolorlight="#000000">
<tr bgcolor="#CCCCCC">
<td align="left" valign="middle" bgcolor="#CCCCCC">文件上传<input type="hidden" name="act" value="upload"></td>
</tr>
<tr align="left" valign="middle" bgcolor="#eeeeee">
<td bgcolor="#eeeeee">
<script language="javascript">
function setid()
{
str='';
if(!window.form1.upcount.value)
window.form1.upcount.value=1;
for(i=1;i<=window.form1.upcount.value;i++)
str+='文件'+i+':<input type="file" name="file'+i+'" style="width:400" class="tx1"><br>';
window.upid.innerHTML=str+'';
}
</script>
<li> 需要上传的个数:<input type="text" name="upcount" class="tx" value="1"><input type="button" name="Button" class="bt" onclick="setid();" value="· 设定 ·">
<li>上传到:<input name="filepath" type="text" class="tx" value="<%= request.QueryString("filepath")%>">
<input name="who" type="hidden" id="who" value="<%= request.QueryString("who")%>">
<li>防止覆盖自动重命名<input name="checkbox" type="checkbox" value="true">
</td>
</tr>
<tr align="center" valign="middle">
<td align="left" id="upid">文件1:<input type="file" name="file1" style="width:400" class="tx1" value=""></td>
</tr>
<tr align="center" valign="middle" bgcolor="#eeeeee">
<td bgcolor="#eeeeee">
<input type="submit" name="Submit" value="· 提交 ·" class="bt" onClick="exec();">
<input type="reset" name="Submit2" value="· 重置 ·" class="bt">
<input type="button" name="Submit2" value="· 取消 ·" class="bt" onClick="window.close();">
</td>
</tr>
</table>
</form></div>
</body>
</html>
<script language="javascript">
setid();
</script>
<%
end if
%>
yslcuk 2004-04-23
  • 打赏
  • 举报
回复
file.SaveAs Server.mappath("image/"&file.FileName)
是上传到你IIS根目录的image目录下
yangchun1983222 2004-04-23
  • 打赏
  • 举报
回复
按照 lhzyn(无心睡眠)的说法,是不是上传到文件夹image下面的呢?
luluso 2004-04-23
  • 打赏
  • 举报
回复
主要是这句:
file.SaveAs Server.mappath(file.FileName)
lhzyn 2004-04-23
  • 打赏
  • 举报
回复
file.SaveAs Server.mappath(file.FileName)
--->
file.SaveAs Server.mappath("image/"&file.FileName)
yangchun1983222 2004-04-23
  • 打赏
  • 举报
回复
没有人回答,自己顶一下

28,404

社区成员

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

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