| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1423 人关注过本帖
标题:上传文件时出现“无效使用 Null ”是什么原因呢?
只看楼主 加入收藏
qjw9004
Rank: 1
等 级:新手上路
帖 子:89
专家分:0
注 册:2011-1-27
结帖率:47.37%
收藏
 问题点数:0 回复次数:6 
上传文件时出现“无效使用 Null ”是什么原因呢?
上传的页面代码
<form method="post" action="wd_yj_upload.asp" name="uploadform" enctype="multipart/form-data" onsubmit="return mysubmit();" >
<ul id="file_group">
<li>文件编号:<%=request.querystring("wdbh")%>
<li>文件名称:<%=request.querystring("wd_name")%>
<li>上传扫描件:<input name="mfile1" type="file" style="WIDTH:70%" />
<li>扫描件名称:<input name="img_name_1" type="text" id="img_name_1" style="WIDTH:57%"> 页码标记:<input name="ym" type="text" id="ym" style="WIDTH:5%" value="<%=totalPut%>" >
<li/><input type="submit" value="上传文件" /><input type="button" value="放弃返回" onClick="window.history.go(-1)">
<input name="flbh" type="hidden" id="flbh" value="<%=request.querystring("flbh")%>" />
<input name="fl_name" type="hidden" id="fl_name" value="<%=request.querystring("fl_name")%>" />
<input name="wdbh" type="hidden" id="wdbh" value="<%=request.querystring("wdbh")%>" />
<input name="wd_name" type="hidden" id="wd_name" value="<%=request.querystring("wd_name")%>" />
</ul>
</FORM>

在upload_5xsoft.inc中
Microsoft VBScript 运行时错误 '800a005e'  
无效使用 Null  
\wdxt\upload_5xsoft.inc, line 44
就是这句话代码
sStart = MidB(RequestData,1, InStrB(iFormStart,RequestData,vbCrlf)-1)

希望朋友们指点~~~
搜索更多相关主题的帖子: return 上传文件 action method file 
2011-11-16 20:15
qjw9004
Rank: 1
等 级:新手上路
帖 子:89
专家分:0
注 册:2011-1-27
收藏
得分:0 
wd_yj_upload.asp代码~~~

<%@LANGUAGE="VBSCRIPT" CODEPAGE="936" %>
<%OPTION EXPLICIT%>
<%Server.ScriptTimeOut=5000%>
<!-- #include file="conn.asp" -->
<!--#include file="upload_5xsoft.inc"-->
<html>
<head>
<meta http-equiv="Content-type" content="text/html; charset=gb2312" />
<title>文件上传</title>
</head>
<body>
<br>文件上传成功!<hr size=1 noshadow width=300 align=left><br>
<%
'Response.Charset="gb2312"
dim upload,file,formName,uploadPath,iCount,fname,fl_name,wdbh,wd_name,rs_wd_yj,sql_wd_yj,ym,totalPut,wdsm,sql_1,img_name_1,MakeFileName

set fl_name=request.form("fl_name")
set wdbh=request.form("wdbh")
set wd_name=request.form("wd_name")
set img_name_1=request.form("img_name_1")
set ym=request.form("ym")
set upload=new upload_5xsoft

'--------------将记录写入数据库(起)---------------------------------------
 sql_1 = "insert into wd_yj (wdbh,wd_name,img_name,img_name_1,wdsm) values ('"&wdbh&"','"&wd_name&"','"&MakeFileName&"','"&img_name_1&"','"&wdsm&"')"
 conn.execute(sql_1)  '执行SQL新增
'--------------将记录写入数据库(起)---------------------------------------

uploadPath="../data/wdxt/wdwj/"&fl_name&"/"
iCount=0

for each formName in upload.objFile
  set file=upload.file(formName)
  if file.FileSize>0 then
    fname=upload.MakeFileName(file.FileExt)
    file.SaveAs Server.mappath(uploadPath & fname)
    iCount=iCount+1
  end if
  set file=nothing
next

set upload=nothing

response.write "<br>"&formName
response.write "<br>" & iCount & " 个文件上传结束![<a href=""javascript:history.back();"">返回</a>]"
%>
</body>
<%
conn.close
set conn = nothing
%>
</html>
2011-11-16 20:17
qjw9004
Rank: 1
等 级:新手上路
帖 子:89
专家分:0
注 册:2011-1-27
收藏
得分:0 
upload_5xsoft.inc代码~~~

<%
dim Data_5xsoft
Class upload_5xsoft
dim objForm,objFile,Version
Public function Form(strForm)
   strForm=lcase(strForm)
   if not objForm.exists(strForm) then
     Form=""
   else
     Form=objForm(strForm)
   end if
 end function

Public function File(strFile)
   strFile=lcase(strFile)
   if not objFile.exists(strFile) then
     set File=new FileInfo
   else
     set File=objFile(strFile)
   end if
 end function

Private Sub Class_Initialize
  dim RequestData,sStart,vbCrlf,sInfo,iInfoStart,iInfoEnd,tStream,iStart,theFile
  dim iFileSize,sFilePath,sFileType,sFormValue,sFileName
  dim iFindStart,iFindEnd
  dim iFormStart,iFormEnd,sFormName
  Version="化境HTTP上传程序 Version 2.1"
  set objForm=Server.CreateObject("Scripting.Dictionary")
  set objFile=Server.CreateObject("Scripting.Dictionary")
  if Request.TotalBytes<1 then Exit Sub
  set tStream = Server.CreateObject("adodb.stream")
  set Data_5xsoft = Server.CreateObject("adodb.stream")
  Data_5xsoft.Type = 1
  Data_5xsoft.Mode =3
  Data_5xsoft.Open
  Data_5xsoft.Write  Request.BinaryRead(Request.TotalBytes)
  Data_5xsoft.Position=0
  RequestData =Data_5xsoft.Read

  iFormStart = 1
  iFormEnd = LenB(RequestData)
  vbCrlf = chrB(13) & chrB(10)
  sStart = MidB(RequestData,1, InStrB(iFormStart,RequestData,vbCrlf)-1)  '这句代码提示错误
  iStart = LenB (sStart)
  iFormStart=iFormStart+iStart+1
  while (iFormStart + 10) < iFormEnd
    iInfoEnd = InStrB(iFormStart,RequestData,vbCrlf & vbCrlf)+3
    tStream.Type = 1
    tStream.Mode =3
    tStream.Open
    Data_5xsoft.Position = iFormStart
    Data_5xsoft.CopyTo tStream,iInfoEnd-iFormStart
    tStream.Position = 0
    tStream.Type = 2
    tStream.Charset ="gb2312"
    sInfo = tStream.ReadText
    tStream.Close
    '取得表单项目名称
    iFormStart = InStrB(iInfoEnd,RequestData,sStart)
    iFindStart = InStr(22,sInfo,"name=""",1)+6
    iFindEnd = InStr(iFindStart,sInfo,"""",1)
    sFormName = lcase(Mid (sinfo,iFindStart,iFindEnd-iFindStart))
    '如果是文件
    if InStr (45,sInfo,"filename=""",1) > 0 then
        set theFile=new FileInfo
        '取得文件名
        iFindStart = InStr(iFindEnd,sInfo,"filename=""",1)+10
        iFindEnd = InStr(iFindStart,sInfo,"""",1)
        sFileName = Mid (sinfo,iFindStart,iFindEnd-iFindStart)
        theFile.FileName=getFileName(sFileName)
        theFile.FilePath=getFilePath(sFileName)
        theFile.FileExt=GetFileExt(sFileName)
        '取得文件类型
        iFindStart = InStr(iFindEnd,sInfo,"Content-Type: ",1)+14
        iFindEnd = InStr(iFindStart,sInfo,vbCr)
        theFile.FileType =Mid (sinfo,iFindStart,iFindEnd-iFindStart)
        theFile.FileStart =iInfoEnd
        theFile.FileSize = iFormStart -iInfoEnd -3
        theFile.FormName=sFormName
        if not objFile.Exists(sFormName) then
          objFile.add sFormName,theFile
        end if
    else
    '如果是表单项目
        tStream.Type =1
        tStream.Mode =3
        tStream.Open
        Data_5xsoft.Position = iInfoEnd
        Data_5xsoft.CopyTo tStream,iFormStart-iInfoEnd-3
        tStream.Position = 0
        tStream.Type = 2
        tStream.Charset ="gb2312"
            sFormValue = tStream.ReadText
            tStream.Close
        if objForm.Exists(sFormName) then
          objForm(sFormName)=objForm(sFormName)&", "&sFormValue         
        else
          objForm.Add sFormName,sFormValue
        end if
    end if
    iFormStart=iFormStart+iStart+1
    wend
  RequestData=""
  set tStream =nothing
End Sub

Private Sub Class_Terminate  
 if Request.TotalBytes>0 then
    objForm.RemoveAll
    objFile.RemoveAll
    set objForm=nothing
    set objFile=nothing
    Data_5xsoft.Close
    set Data_5xsoft =nothing
 end if
End Sub
   
 Private function GetFilePath(FullPath)
  If FullPath <> "" Then
   GetFilePath = left(FullPath,InStrRev(FullPath, "\"))
  Else
   GetFilePath = ""
  End If
 End  function

 Private function GetFileExt(FullPath)
  If FullPath <> "" Then
   GetFileExt = mid(FullPath,InStrRev(FullPath, ".")+1)
  Else
   GetFileExt = ""
  End If
 End  function
 
 Private function GetFileName(FullPath)
  If FullPath <> "" Then
   GetFileName = mid(FullPath,InStrRev(FullPath, "\")+1)
  Else
   GetFileName = ""
  End If
 End  function

Public Function MakeFileName(Ext)
    If Ext<>"" Then
        '''Dim DateYear,DateMonth,DateDay,DateHour,DateMinute,DateSecond,FileRnd
        '''DateYear=Year(Now())
        '''DateMonth=Month(Now())
        '''DateDay=Day(Now())
        '''DateHour=Hour(Now())
        '''DateMinute=Minute(Now())
        '''DateSecond=Second(Now())
        '''If Len(DateMonth)<2 Then DateMonth="0" & DateMonth
        '''If Len(DateDay)<2 Then DateDay="0" & DateDay
        '''If Len(DateHour)<2 Then DateHour="0" & DateHour
        '''If Len(DateMinute)<2 Then DateMinute="0" & DateMinute
        '''If Len(DateSecond)<2 Then DateSecond="0" & DateSecond
        '''Randomize
        '''FileRnd=CStr(Int(Rnd()*1000))
        '''If Len(FileRnd)=2 Then FileRnd="0" & FileRnd
        '''If Len(FileRnd)=1 Then FileRnd="00" & FileRnd
        '''MakeFileName=DateYear & DateMonth & DateDay & DateHour & DateMinute & DateSecond & FileRnd & "." & Ext
        MakeFileName= wd_name &"_"&ym&"." & Ext
    End If
End Function

End Class

Class FileInfo
  dim FormName,FileName,FilePath,FileSize,FileExt,FileType,FileStart
  Private Sub Class_Initialize
    FileName = ""
    FilePath = ""
    FileSize = 0
    FileStart= 0
    FormName = ""
    FileType = ""
    FileExt  = ""
  End Sub
  
 Public function SaveAs(FullPath)
    dim dr,ErrorChar,i
    SaveAs=true
    if trim(fullpath)="" or FileStart=0 or FileName="" or right(fullpath,1)="/" then exit function
    set dr=CreateObject("Adodb.Stream")
    dr.Mode=3
    dr.Type=1
    dr.Open
    Data_5xsoft.position=FileStart
    Data_5xsoft.copyto dr,FileSize
    dr.SaveToFile FullPath,2
    dr.Close
    set dr=nothing
    SaveAs=false
  end function
  End Class
%>










文件上传成功!

0 then
    fname=upload.MakeFileName(file.FileExt)
    file.SaveAs Server.mappath(uploadPath & fname)
    iCount=iCount+1
  end if
  set file=nothing
next

set upload=nothing

response.write "
"&formName
response.write "
" & iCount & " 个文件上传结束![返回]"
%>




[ 本帖最后由 qjw9004 于 2011-11-16 23:38 编辑 ]
2011-11-16 20:19
qjw9004
Rank: 1
等 级:新手上路
帖 子:89
专家分:0
注 册:2011-1-27
收藏
得分:0 
有人帮帮吗?
2011-11-16 22:36
qjw9004
Rank: 1
等 级:新手上路
帖 子:89
专家分:0
注 册:2011-1-27
收藏
得分:0 
在线等待着!~~
2011-11-16 23:38
qjw9004
Rank: 1
等 级:新手上路
帖 子:89
专家分:0
注 册:2011-1-27
收藏
得分:0 
有人帮看看吗?
2011-11-17 08:00
qjw9004
Rank: 1
等 级:新手上路
帖 子:89
专家分:0
注 册:2011-1-27
收藏
得分:0 
嗨!没个人能帮帮吗?
2011-11-17 11:48
快速回复:上传文件时出现“无效使用 Null ”是什么原因呢?
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.017084 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved