上传过程中,对文本进行批量替换,再建立文本,提示无权限。代码如下:upfiles.asp<%Server.ScriptTimeOut=5000%>
<!--#include FILE="upload_5xsoft.inc"-->
<html>
<head>
<title>文件上传</title>
</head>
<body>
<br>化境文件上传!<hr size=1 noshadow width=300 align=left><br><br>
<% Function testDate(s)
Dim re
Set re = New RegExp
With re
.Pattern = "^\d{4}\/\d{2}\/\d{2}" '匹配规则-起始以4位数字的年月日规则 对象RegExp属性。
testDate = .Test(s) '执行搜索并返回 对象RegExp方法
End With
Set re = Nothing
End FunctionFunction testTime(s)
Dim re
Set re = New RegExp
With re
.Pattern = "^\d{2}\:\d{2}\:\d{2}"
testTime = .Test(s)
End With
Set re = Nothing
End FunctionFunction getDate(s)
Dim re, col
Set re = New RegExp
With re
.Pattern = "^\d{4}\/\d{2}\/\d{2}"
Set col = .Execute(s)
End With
Set re = Nothing
getDate = Replace(col(0), "/", "")
End FunctionFunction getTime(s, dt)
Dim re, col, t
Set re = New RegExp
With re
.Pattern = "^\d{2}\:\d{2}\:\d{2}"
Set col = .Execute(s)
End With
Set re = Nothing
t = Replace(col(0), ":", "")
s = Replace(s, col(0), t)
getTime = dt & s
End Functiondim upload,file,formName,formPath,savePath,iCount
set upload=new upload_5xsoft ''建立上传对象response.write upload.Version&"<br><br>" ''显示上传类的版本if upload.form("filepath")="" then ''得到上传目录
HtmEnd "请输入要上传至的目录!"
set upload=nothing
response.end
else
formPath=upload.form("filepath")
''在目录后加(/)
if right(formPath,1)<>"/" then formPath=formPath&"/"
end ifif upload.form("filepath")="" then ''得到保存目录
HtmEnd "请输入要保存到的目录!"
' set upload=nothing
response.end
else
savePath=upload.form("savepath")
''在目录后加(/)
if right(savePath,1)<>"/" then savePath=svaePath&"/"
end ifiCount=0
for each formName in upload.objForm ''列出所有form数据
response.write formName&"="&upload.form(formName)&"<br>"
nextresponse.write "<br>"
for each formName in upload.objFile ''列出所有上传了的文件
set file=upload.file(formName) ''生成一个文件对象
if file.FileSize>0 then ''如果 FileSize > 0 说明有文件数据
file.SaveAs Server.mappath(formPath&file.FileName) ''保存文件
cur = ""
s = ""
response.write file.FilePath&file.FileName&" ("&file.FileSize&") => "&formPath&File.FileName&" 文本转换成功!<br>"
iCount=iCount+1
Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.OpenTextFile(file.FileName, 1, True)
set newstr = fso.Createtextfile(savePath&file.FileName, 1, Ture)
Do While Not f.AtEndOfStream
line = Trim(f.ReadLine())
If testDate(line) Then
cur = getDate(line)
ElseIf testTime(line) Then
s = s & getTime(line, cur) & VBCrLf
End If
Loop
newstr.WriteLine(s)
f.Close
Set f = Nothing
Set fso = Nothing
end if
set file=nothing
nextset upload=nothing ''删除此对象
Htmend iCount&" 个文件上传结束!"sub HtmEnd(Msg)
set upload=nothing
response.write "<br>"&Msg&" [<a href=""javascript:history.back();"">返回</a>]</body></html>"
response.end
end sub
%>
</body>
</html>之前是两个独立的代码运行都是正常的,拼合后,就出现这样的问题,也就是说:上传是正常的,批量替换也是正常的。望哪位好心的朋友有时间帮忙看一下。感激不尽...
<!--#include FILE="upload_5xsoft.inc"-->
<html>
<head>
<title>文件上传</title>
</head>
<body>
<br>化境文件上传!<hr size=1 noshadow width=300 align=left><br><br>
<% Function testDate(s)
Dim re
Set re = New RegExp
With re
.Pattern = "^\d{4}\/\d{2}\/\d{2}" '匹配规则-起始以4位数字的年月日规则 对象RegExp属性。
testDate = .Test(s) '执行搜索并返回 对象RegExp方法
End With
Set re = Nothing
End FunctionFunction testTime(s)
Dim re
Set re = New RegExp
With re
.Pattern = "^\d{2}\:\d{2}\:\d{2}"
testTime = .Test(s)
End With
Set re = Nothing
End FunctionFunction getDate(s)
Dim re, col
Set re = New RegExp
With re
.Pattern = "^\d{4}\/\d{2}\/\d{2}"
Set col = .Execute(s)
End With
Set re = Nothing
getDate = Replace(col(0), "/", "")
End FunctionFunction getTime(s, dt)
Dim re, col, t
Set re = New RegExp
With re
.Pattern = "^\d{2}\:\d{2}\:\d{2}"
Set col = .Execute(s)
End With
Set re = Nothing
t = Replace(col(0), ":", "")
s = Replace(s, col(0), t)
getTime = dt & s
End Functiondim upload,file,formName,formPath,savePath,iCount
set upload=new upload_5xsoft ''建立上传对象response.write upload.Version&"<br><br>" ''显示上传类的版本if upload.form("filepath")="" then ''得到上传目录
HtmEnd "请输入要上传至的目录!"
set upload=nothing
response.end
else
formPath=upload.form("filepath")
''在目录后加(/)
if right(formPath,1)<>"/" then formPath=formPath&"/"
end ifif upload.form("filepath")="" then ''得到保存目录
HtmEnd "请输入要保存到的目录!"
' set upload=nothing
response.end
else
savePath=upload.form("savepath")
''在目录后加(/)
if right(savePath,1)<>"/" then savePath=svaePath&"/"
end ifiCount=0
for each formName in upload.objForm ''列出所有form数据
response.write formName&"="&upload.form(formName)&"<br>"
nextresponse.write "<br>"
for each formName in upload.objFile ''列出所有上传了的文件
set file=upload.file(formName) ''生成一个文件对象
if file.FileSize>0 then ''如果 FileSize > 0 说明有文件数据
file.SaveAs Server.mappath(formPath&file.FileName) ''保存文件
cur = ""
s = ""
response.write file.FilePath&file.FileName&" ("&file.FileSize&") => "&formPath&File.FileName&" 文本转换成功!<br>"
iCount=iCount+1
Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.OpenTextFile(file.FileName, 1, True)
set newstr = fso.Createtextfile(savePath&file.FileName, 1, Ture)
Do While Not f.AtEndOfStream
line = Trim(f.ReadLine())
If testDate(line) Then
cur = getDate(line)
ElseIf testTime(line) Then
s = s & getTime(line, cur) & VBCrLf
End If
Loop
newstr.WriteLine(s)
f.Close
Set f = Nothing
Set fso = Nothing
end if
set file=nothing
nextset upload=nothing ''删除此对象
Htmend iCount&" 个文件上传结束!"sub HtmEnd(Msg)
set upload=nothing
response.write "<br>"&Msg&" [<a href=""javascript:history.back();"">返回</a>]</body></html>"
response.end
end sub
%>
</body>
</html>之前是两个独立的代码运行都是正常的,拼合后,就出现这样的问题,也就是说:上传是正常的,批量替换也是正常的。望哪位好心的朋友有时间帮忙看一下。感激不尽...
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货