文件写入问题(在线等待)

wenyuxu 2005-05-18 07:05:46
各位:
为什么我在本地测试通过,放到internet服务器上就提示文件写入错误呢
代码如下
<SCRIPT RUNAT=SERVER LANGUAGE=VBSCRIPT>
'''''用这个程序上传文件时,表单的submit按钮必须有命名,任何名称均可
Dim upfile_5xSoft_Stream
Class upload_5xSoft
Dim Form, File, Version
Private Sub Class_Initialize
Dim iStart, iFileNameStart, iFileNameEnd, iEnd, vbEnter, iFormStart, iFormEnd, theFile
Dim strDiv, mFormName, mFormValue, mFileName, mFileSize, mFilePath, iDivLen, mStr
Version = ""
If Request.TotalBytes < 1 Then Exit Sub
Set Form = CreateObject("Scripting.Dictionary")
Set File = CreateObject("Scripting.Dictionary")
Set upfile_5xSoft_Stream = CreateObject("Adodb.Stream")
upfile_5xSoft_Stream.Mode = 3
upfile_5xSoft_Stream.Type = 1
upfile_5xSoft_Stream.Open
upfile_5xSoft_Stream.write Request.BinaryRead(Request.TotalBytes)
vbEnter = Chr(13) & Chr(10)
iDivLen = inString(1, vbEnter) + 1
strDiv = subString(1, iDivLen)
iFormStart = iDivLen
iFormEnd = inString(iFormStart, strDiv) - 1
While iFormStart < iFormEnd
iStart = inString(iFormStart, "name=""")
iEnd = inString(iStart + 6, """")
mFormName = subString(iStart + 6, iEnd - iStart - 6)
iFileNameStart = inString(iEnd + 1, "filename=""")
If iFileNameStart > 0 And iFileNameStart < iFormEnd Then
iFileNameEnd = inString(iFileNameStart + 10, """")
mFileName = subString(iFileNameStart + 10, iFileNameEnd - iFileNameStart - 10)
iStart=inString(iFileNameEnd+1,vbEnter&vbEnter)
iEnd=inString(iStart+4,vbEnter&strDiv)
If iEnd > iStart Then
mFileSize = iEnd - iStart - 4
Else
mFileSize = 0
End If
Set theFile = New FileInfo
theFile.FileName = GetFileName(mFileName)
theFile.FilePath = GetFilePath(mFileName)
theFile.FileSize = mFileSize
theFile.FileStart = iStart + 4
theFile.FormName = FormName
File.Add mFormName, theFile
Else
iStart=inString(iEnd+1,vbEnter&vbEnter)
iEnd=inString(iStart+4,vbEnter&strDiv)
If iEnd > iStart Then
mFormValue = subString(iStart + 4, iEnd - iStart - 4)
Else
mFormValue = ""
End If
Form.Add mFormName, mFormValue
End If
iFormStart = iFormEnd + iDivLen
iFormEnd = inString(iFormStart, strDiv) - 1
Wend
End Sub
Private Function subString(theStart, theLen)
Dim i, c, stemp
upfile_5xSoft_Stream.Position = theStart - 1
stemp = ""
For i = 1 To theLen
If upfile_5xSoft_Stream.EOS Then Exit For
c = AscB(upfile_5xSoft_Stream.Read(1))
If c > 127 Then
If upfile_5xSoft_Stream.EOS Then Exit For
stemp=stemp&Chr(AscW(ChrB(AscB(upfile_5xSoft_Stream.Read(1)))&ChrB(c)))
i = i + 1
Else
stemp=stemp&Chr(c)
End If
Next
subString = stemp
End Function
Private Function inString(theStart, varStr)
Dim i, j, bt, theLen, Str
inString = 0
Str = toByte(varStr)
theLen = LenB(Str)
For i = theStart To upfile_5xSoft_Stream.Size - theLen
If i > upfile_5xSoft_Stream.Size Then Exit Function
upfile_5xSoft_Stream.Position = i - 1
If AscB(upfile_5xSoft_Stream.Read(1)) = AscB(MidB(Str, 1)) Then
inString = i
For j = 2 To theLen
If upfile_5xSoft_Stream.EOS Then
inString = 0
Exit For
End If
If AscB(upfile_5xSoft_Stream.Read(1)) <> AscB(MidB(Str, j, 1)) Then
inString = 0
Exit For
End If
Next
If inString <> 0 Then Exit Function
End If
Next
End Function
Private Sub Class_Terminate
Form.RemoveAll
File.RemoveAll
Set Form = Nothing
Set File = Nothing
upfile_5xSoft_Stream.Close
Set upfile_5xSoft_Stream = Nothing
End Sub
Private Function GetFilePath(FullPath)
If FullPath <> "" Then
GetFilePath = Left(FullPath, InStrRev(FullPath, "\"))
Else
GetFilePath = ""
End If
End Function
Private Function GetFileName(FullPath)
If FullPath <> "" Then
GetFileName = Mid(FullPath, InStrRev(FullPath, "\") + 1)
Else
GetFileName = ""
End If
End Function
Private Function toByte(Str)
Dim i, iCode, c, iLow, iHigh
toByte = ""
For i = 1 To Len(Str)
c = Mid(Str, i, 1)
iCode = Asc(c)
If iCode < 0 Then iCode = iCode + 65535
If iCode > 255 Then
iLow = Left(Hex(Asc(c)), 2)
iHigh = Right(Hex(Asc(c)), 2)
toByte = toByte & ChrB("&H" & iLow) & ChrB("&H" & iHigh)
Else
toByte = toByte & ChrB(AscB(c))
End If
Next
End Function
End Class
Class FileInfo
Dim FormName, FileName, FilePath, FileSize, FileStart
Private Sub Class_Initialize()
FileName = ""
FilePath = ""
FileSize = 0
FileStart = 0
FormName = ""
End Sub
Public Function SaveAs(FullPath)
Dim dr, ErrorChar, i
SaveAs = 1
If Trim(FullPath) = "" Or FileSize = 0 Or FileStart = 0 Or FileName = "" Then Exit Function
If FileStart = 0 Or Right(FullPath, 1) = "/" Then Exit Function
Set dr = CreateObject("Adodb.Stream")
dr.Mode = 3
dr.Type = 1
dr.Open
upfile_5xSoft_Stream.Position = FileStart - 1
upfile_5xSoft_Stream.copyto dr, FileSize

dr.SaveToFile FullPath, 2 ' //在此处报错******************************

dr.Close
Set dr = Nothing
SaveAs = 0
End Function
End Class
</SCRIPT>
...全文
77 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
hfwpq 2005-05-18
  • 打赏
  • 举报
回复
先看看路径是否存在,再看看文件目录的权限,everyone是否有写的权限
wenyuxu 2005-05-18
  • 打赏
  • 举报
回复
错误提示:ADODB.Stream 错误 ‘800a0bbc’,写入文件失败
wenyuxu 2005-05-18
  • 打赏
  • 举报
回复
asp文件
<%
dim ID
dim upload,path,file1,filename1
set upload=new upload_5xSoft ''建立上传对象
formPath="/uploadtables/"
'开始上传
set file1=upload.file("bigimage")
'filename1=year(now())&"-"&month(now())&"-"&day(now())&"_"&hour(now())&"-"&Minute(now())&"-"&Second(now()) & right(file1.FileName,4)
filename1=year(now())&month(now())&day(now())&hour(now())&Minute(now())&Second(now()) & file1.FileName
if file1.FileSize>0 then ''如果 FileSize > 0 说明有文件数据

response.Write(formPath&filename1)
'response.end
file1.SaveAs Server.mappath(formPath&filename1) ''保存文件
path2= "/uploadtables/"& filename1
else
response.write "请选择要上传得文档"
end if

response.Write(formPath&filename1)

%>

函数文件
Public Function SaveAs(FullPath)
Dim dr, ErrorChar, i
SaveAs = 1
If Trim(FullPath) = "" Or FileSize = 0 Or FileStart = 0 Or FileName = "" Then Exit Function
If FileStart = 0 Or Right(FullPath, 1) = "/" Then Exit Function
Set dr = CreateObject("Adodb.Stream")
dr.Mode = 3
dr.Type = 1
dr.Open
upfile_5xSoft_Stream.Position = FileStart - 1
upfile_5xSoft_Stream.copyto dr, FileSize

dr.SaveToFile FullPath, 2

dr.Close
Set dr = Nothing
SaveAs = 0
End Function
jarraytan 2005-05-18
  • 打赏
  • 举报
回复
大哥,代码也太长了吧?贴点核心的代码和问题出来就可以了。

28,406

社区成员

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

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