为什么文件为空/?!
<%
function getRemoteFiles(remotePath,localPath,filename)
On Error Resume Next
'取得流
strbody=getBody(remotePath)
'取得保存的文件名
if right(localPath,1)<>"\" then
localPath=localPath & "\"
end if
filePath=localPath & getFileName(remotePath,filename)
'保存文件
if SaveToFile(strbody,filePath)=true and err.number=0 then
getRemoteFile=true
else
getRemoteFile=false
end if
end function
'获取远程内容
function getBody(url)
set retrieval=Server.CreateObject("microsoft.xmlhttp")
with retrieval
.Open "get",url,false,"",""
.Send
getBody=.ResponseBody
end with
set retrieval=nothing
end function
'重组文件名
function getFileName(remotePath,filename)
arrTmp=split(remotePath,".")
strFileExt=arrTmp(ubound(arrTmp))
getFileName=filename & "." & strFileExt
end function
'将内容保存为文件
function saveToFile(stream,filePath)
On Error Resume Next
set objStream=server.CreateObject("adodb.stream")
with objStream
.Type=1
.Open
.Write stream
.SaveToFile filePath,2
.Close()
end with
set objStream=nothing
if err.number<>0 then
saveToFile=false
else
saveToFile=true
end if
end function
strremotePath=Request.Form("123")
strlocalPath=Server.MapPath("include")
getRemoteFiles strremotePath,strlocalPath,ddr
%>
我在自己的机子上测试,结果上传什么文件,都变成了空文件,内容没有,连名字也没有
怎么会事(我第一次见可以没有名字的文件)!