这个问题我问了好几次,好像没有人回答清楚!

xdszg 2004-01-08 11:18:15
贴出我的代码!

test1.asp

<html>
<head>
<title>copytest</title>
</head>
<!--#INCLUDE FILE="COMMON1.asp"-->
<body>
<h1>file choose</h1>
<FORM METHOD="POST" action="t.asp" name="form1">
<INPUT TYPE="FILE" NAME="fromfile" size=60>
<INPUT TYPE="button" VALUE="Send" name="send" onclick="Setei">
</FORM>
<p>
</body>
<script language="vbscript">
Sub Setei()
dim i
dim aaa
dim bbb
aaa = form1.fromfile.value

bbb= "\\172.28.121.49\income"
msgbox(aaa)
msgbox(bbb)

i = UploadFile(aaa,bbb)
msgbox(i)

form1.Submit()
End Sub
</script>
</html>

COMMON1.asp

<script language="vbscript">
Function UploadFile(src,dest)
UploadFile = 0

On Error Resume Next
Err.Clear

Dim lsrc1
Dim fso
Dim lenth
Dim inttmp
Dim strtmp
Dim i
inttmp = 0
strtmp = ""

Set fso = CreateObject("Scripting.FileSystemObject")

if Right(src,1) = "\" then
lsrc1 = Left( src , Len(src) - 1 )
else
lsrc1 = src
end if
lenth = len(lsrc1)
if lenth > 0 then
for i =1 to lenth
strtmp = Mid(lsrc1,lenth-i,1)
if strtmp = "\" then
strtmp = Right(lsrc1,i+1)
exit for
end if
next
end if

if len(strtmp) > 0 then
strtmp = dest & strtmp
else
UploadFile = 0
exit Function
end if

fso.CopyFile lsrc1,strtmp

Set fso = Nothing

if Err.Number <> 0 then
UploadFile = 0
else
UploadFile = 1
end if

End Function
</script>

运行提示:COMMON1.asp的
Set fso = CreateObject("Scripting.FileSystemObject")
出错。
信息:Active控件的对象不能做成.

我折腾了好久都不行,是什么原因?
解决了再送100分。


...全文
107 20 打赏 收藏 转发到动态 举报
写回复
用AI写文章
20 条回复
切换为时间正序
请发表友善的回复…
发表回复
liuzxit 2004-01-08
  • 打赏
  • 举报
回复
客戶端預設的安全等級不允許用CreateObject("Scripting.FileSystemObject")的
xdszg 2004-01-08
  • 打赏
  • 举报
回复
xieyj(Free Fish) 讲的是对的。
但还有个问题。
我改写了一个版本,为什么就不能运行了?
差异就是多了<% %>。
运行出错提示:不能写入。
有什么方法解决吗?
贴出代码。

test.asp

<html>
<head>
<title>copy test</title>
</head>
<!--#INCLUDE FILE="COMMON.asp"-->
<body>
<%
dim i
dim aaa
dim bbb

aaa = "C:\Inetpub\wwwroot\TOUGOU\HINSITU1.asp"
bbb= "\\172.28.121.49\income"

response.write "Source:"&aaa&"<BR>"
response.write "Dest:"&bbb&"<BR>"

i = UploadFile(aaa,bbb)
%>
</body>
</html>

COMMON.asp
<%
Function UploadFile(src,dest)
UploadFile = 0

On Error Resume Next
Err.Clear

Dim lsrc1
Dim fso
Dim lenth
Dim inttmp
Dim strtmp
Dim i
inttmp = 0
strtmp = ""

Set fso = CreateObject("Scripting.FileSystemObject")

if Right(src,1) = "\" then
lsrc1 = Left( src , Len(src) - 1 )
else
lsrc1 = src
end if
lenth = len(lsrc1)
if lenth > 0 then
for i =1 to lenth
strtmp = Mid(lsrc1,lenth-i,1)
if strtmp = "\" then
strtmp = Right(lsrc1,i+1)
exit for
end if
next
end if

if len(strtmp) > 0 then
strtmp = dest & strtmp
else
UploadFile = 0
exit Function
end if

fso.CopyFile lsrc1,strtmp

if err.number <> 0 then
response.write err.description
end if

Set fso = Nothing

if Err.Number <> 0 then
UploadFile = 0
else
UploadFile = 1
end if

End Function
%>
liuzxit 2004-01-08
  • 打赏
  • 举报
回复
客戶端是不能用預設的安全等級不允許用CreateObject("Scripting.FileSystemObject")的
freetaiger 2004-01-08
  • 打赏
  • 举报
回复
这是在客户端,不能定义fso对象
只能在服务器端的使用
swich 2004-01-08
  • 打赏
  • 举报
回复
ygghost 2004-01-08
  • 打赏
  • 举报
回复
1 fso组件出错 (可能性不是很大)
这个组件在c:\winnt\system32\scrrun.dll.
运行里面反注册 然后再注册。

2 scripting坏掉
到Microsoft主站搜索这个关键字,安装一下最新的版本。
xieyj 2004-01-08
  • 打赏
  • 举报
回复
客户端不支持 fso ,你在"工具"中的" internet 选项..."中"安全"设置一下级别就可以了
angelheavens 2004-01-08
  • 打赏
  • 举报
回复
On Runtime Server Side:

Set fso = Server.CreateObject("Scripting.FileSystemObject")
xdszg 2004-01-08
  • 打赏
  • 举报
回复
可以,我其他ASP程序用过FSO组件。
zhuomaocn 2004-01-08
  • 打赏
  • 举报
回复
先看一下服务器上FSO这个组件有没有注册了。
xdszg 2004-01-08
  • 打赏
  • 举报
回复
映射为本地硬盘 我也试过,好像也不行。
bingofei 2004-01-08
  • 打赏
  • 举报
回复
把\\172.28.121.49\income 映射为本地硬盘再进行操作。
xdszg 2004-01-08
  • 打赏
  • 举报
回复
TO windancer(风精灵)
权限已经完全开放了,everyone都可以写入。
TO:alexzhang00(三角猫(sjcatsoft))
是我们公司内部网络的IP地址。没错的。

我现在就觉得是不是我的\\172.28.121.49\income
共享那里可能还没有设置对。
\\172.28.121.49系统是win2000pro。

有人能解决吗?
wanghuixue 2004-01-08
  • 打赏
  • 举报
回复
客户端IE->"工具"->" internet 选项..."->"安全"设置一下级别就可以了
本地Intranet 和 Internet 都要设置,所有涉及Active控件的选项都设为“启用”即可
DeltaCat 2004-01-08
  • 打赏
  • 举报
回复
看IP地址,不是LAN的啊
DeltaCat 2004-01-08
  • 打赏
  • 举报
回复
你对 \\172.28.121.49\income 有写入权限吗?
windancer 2004-01-08
  • 打赏
  • 举报
回复
你确认程序对\\172.28.121.49\income有写入权限?
ArvinGuo712 2004-01-08
  • 打赏
  • 举报
回复
你的代码我看来,像是非法程序,你要干吗?
celerylhl 2004-01-08
  • 打赏
  • 举报
回复
不要试图在客户端使用 FSO
xdszg 2004-01-08
  • 打赏
  • 举报
回复
TO:liuzxit(八爪魚)
我说的是修改后的另一个版本,为什么出错,好像不是
Scripting.FileSystemObject的原因。

28,407

社区成员

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

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