首页 新闻 论坛 群组 Blog 文档 下载 读书 Tag 网摘 搜索 .NET Java 游戏 视频 人才 外包 培训 数据库 书店 程序员
中国软件网
欢迎您:游客 | 登录 注册 帮助
  • 使用“化境无组件上传”字符串无法获取,非常急!!!
    进入用户个人空间
    加为好友
    发送私信
    在线聊天
    发表于:2008-05-11 15:41:37 楼主
    相信不少人都用化境无组件上传(http://www.5xsoft.com/upload.html),这个东西确实强大
    可是我这里不知道怎么弄的,无法获取表单中text的值
    明天要交的,但是弄到现在还没解决
    各位大哥帮帮忙吧!!!!

    process.asp

    <%OPTION EXPLICIT%>
    <%Server.ScriptTimeOut=5000%>
    <!--#include FILE="upload_5xsoft.inc"-->
    <%
    dim upload,file,formName,formPath
    dim bid,Image_Set,Conn,Rs,sqlstr,sql
    set upload=new upload_5xsoft ''建立上传对象

    bid=upload.form("text1")
    for each formName in upload.objFile ''列出所有上传了的文件
    set file=upload.file("img")  ''生成一个文件对象
    Image_Set=file.FileName
    if file.FileSize>0 then        ''如果 FileSize > 0 说明有文件数据
      file.SaveAs Server.mappath("img/"&file.FileName)  ''保存文件
    end if
    set file=nothing
    next

    set upload=nothing  ''删除此对象

    Set Conn=Server.createobject("ADODB.Connection")
    conn.open "driver={microsoft access driver (*.mdb)};dbq="&server.mappath("database/bus.mdb")
    Set Rs=Server.CreateObject("ADODB.RecordSet")
    sqlstr="SELECT * FROM busmap WHERE busid='" &bid&"' "
    Rs.Open Sqlstr,Conn,1,3
      if rs.recordcount = 0 then
      rs.close 
      sql="SELECT * FROM busmap where id is null"
      rs.Open sql,conn,1,3   
      rs.addnew
      Rs("busid")=bid
      Rs("busmap")=Image_Set 
      else
      Rs("busmap")=Image_Set
      end if   
      rs.update
      rs.Close   
      set rs=nothing   
      conn.Close
    %>


    upload_5xsoft.inc
    <SCRIPT RUNAT=SERVER LANGUAGE=VBSCRIPT>
    dim Data_5xsoft

    Class upload_5xsoft
     
    dim objForm,objFile

    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
      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
    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
    </SCRIPT>
    100  修改 删除 举报 引用 回复
    进入用户个人空间
    加为好友
    发送私信
    在线聊天
    发表于:2008-05-11 15:44:591楼 得分:0
    就是process.asp 中的这句
    bid=upload.form("text1")
    得到的总是空值
    修改 删除 举报 引用 回复
    进入用户个人空间
    加为好友
    发送私信
    在线聊天
    发表于:2008-05-11 16:20:342楼 得分:0
    bid=upload.form("text1")改成  bid=upload.Form("text1")试试。
    修改 删除 举报 引用 回复
    进入用户个人空间
    加为好友
    发送私信
    在线聊天
    发表于:2008-05-11 16:28:283楼 得分:0
    还是不行,我郁闷
    改个大小写貌似没什么分别啊
    修改 删除 举报 引用 回复
    进入用户个人空间
    加为好友
    发送私信
    在线聊天
    发表于:2008-05-11 16:35:254楼 得分:0
    空值就要看你上一页的了
    修改 删除 举报 引用 回复
    进入用户个人空间
    加为好友
    发送私信
    在线聊天
    发表于:2008-05-11 16:38:485楼 得分:0
    上一页??上一页的form的action就是这个process.asp啊

    上一页的代码如下:
    <%@LANGUAGE="VBSCRIPT"%>
    <% option explicit %>
    <!--#include file="admin_check.asp"-->
    <!--#include file="conn.asp"-->
    <!--#include file="function.asp"-->
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
    <title>增加车次 </title>
    <style type="text/css">
    body,tr,td {
    font-family: 宋体;
    font-size: 13px
    }
    img{CURSOR: hand;}
    </style>
    <script language="JavaScript">
    function addItem(){
    var t2=document.form1.text2;
    var t3=document.form1.text3;
    var flag=false;
    if (t2.value != ""){
    for (i=0;i <t3.length;i++){
    if (t2.value==t3.options[i].text){
    flag=true;
    break;
    }
    }
    if (flag){
    alert("添加的站点名称已经存在");
    }else{
    t3[t3.length++].text=t2.value;
    }
    t2.value="";
    t2.focus();
    }
    }
    function delItem(){
    var t3=document.form1.text3;
    if (t3.selectedIndex >= 0){
    t3.remove(t3.selectedIndex++);
    }
    }
    function selectAllItem(){
    var t3=document.form1.text3;
    for (i=0;i <t3.length;i++){
    t3.options[i].selected=true;
    }
    }
    function keyDown(){
    //alert(window.event.keyCode);
    if(window.event.keyCode==13){
    addItem();
    }
    }
    function doCheck(){
    var f=document.form1;
    if (f.text1.value==""){
    alert("请填写车次!");
    f.text1.focus();
    }else if(f.text3.length < 2){ //至少要填写两个站点
    alert("至少要输入两个站点");
    f.text2.focus();
    }else{
    selectAllItem();
    f.submit();
    }
    }
    </script>
    <script language="JavaScript" type="text/JavaScript">
    <!--
    function MM_reloadPage(init) {  //reloads the window if Nav4 resized
      if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
        document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
      else if (innerWidth!=document.MM_pgW ¦ ¦ innerHeight!=document.MM_pgH) location.reload();
    }
    MM_reloadPage(true);
    //-->
    </script>
    <script language="javascript" type="text/javascript">
    function opendiv(){
    var busid=document.form1.text1.value;
    if (busid==""){
    alert("请填写车次!");
    document.form1.text1.focus();
    }
    else{
    layer2.style.display ='none';
    layer1.style.display ='block';
    mapfrm.text.value = busid;
    layer1.style.left = 100;
    layer1.style.top = 100;
    }
    }
    </script>
    </head>

    <body bgcolor="#E8F3FF" leftmargin="0" topmargin="0">
    <div id="layer1" name="layer1" style="Z-INDEX:1;WIDTH:500px;POSITION:absolute;HEIGHT:264px;display:none;">
      <form action="upfile.asp" enctype="multipart/form-data" method="POST" name="mapfrm">
    <table width="400" height="200" align="center" bgcolor="#003399">
    <tr bgcolor="#E8F3FF">
    <td>车次: <input type="text" size="20" name="text" disabled="1"> </td>
    </tr>
    <tr bgcolor="#E8F3FF"> <td>选择路线图: <input type="file" name="img" </td> </tr>
    <tr bgcolor="#E8F3FF"> <td align="center">
    <input name="Submit" type="submit" value="保存修改"/>&nbsp;&nbsp;
        <input name="closeeditwindow" type="button" value="取消保存" onclick="layer1.style.display ='none';layer2.style.display ='block';" />
    </td> </tr>
    </table>
      </form>
      </div>
      <div id="layer2" name="layer2" style="Z-INDEX:0;POSITION:absolute;">
    <form action="admin_save.asp" method="post" name="form1"  enctype="multipart/form-data">
    <table width="100%" height="100%" border="0" bgcolor="#003399" cellpadding="3" cellspacing="1" align="center">
      <tr>
        <td height="20" background="images/topbg.gif"> </td>
      </tr>
      <tr bgcolor="#7DA4EC">
        <td> <strong> <font color="#FFFFFF">增加车次--管理员 </font> </strong> </td>
      </tr>
      <tr bgcolor="#E8F3FF">
        <td> <div align="left" style="font-size:20px"> <strong> <font color="#000099">步骤① </font> </strong> </div> </td>
      </tr>
        <tr bgcolor="#E8F3FF">
          <td>请输入车次
            <input name="text1" type="text" id="text1">
            ( <font color="#FF0000">* </font>车次不能包含以下字符: <font color="#FF0000">; ¦ 空格 </font>) </td>
      </tr>
      <tr bgcolor="#E8F3FF">
        <td> <div align="left" style="font-size:20px"> <strong> <font color="#000099">步骤② </font> </strong> </div> </td>
      </tr>
        <tr bgcolor="#E8F3FF">
          <td> <p>请依次在输入站点名称,添加到站点列表( <font color="#FF0000">* </font>站名不能包含以下字符: <font color="#FF0000">;
              ¦ 空格 </font>) <br>
              添加:在左侧输入站名,然后按添加按扭,或者直接敲回车,也会添加到站点列表 <br>
              移除:在右侧选中相应的站名,然后点移除按扭 </p>
            <table width="500" border="1" cellspacing="0" cellpadding="0">
              <tr>
                <td width="123" align="center">站点名称 <br>
                  <input name="text2" type="text" id="text2" style="width:130px" onKeyDown="keyDown()"> </td>
                <td width="116" align="center">
    <p>
                    <input type="button" name="button1" value="添  加 &gt;&gt;" onClick="addItem()">
                  </p>
                  <p>
                    <input type="button" name="button2" value="&lt;&lt; 移  除" onClick="delItem()">
                  </p> </td>
                <td width="203"> <select name="text3" multiple id="text3" style="width:200px;height:220px;">
                  </select> </td>
              </tr>
            </table> </td>
      </tr>
      <tr bgcolor="#E8F3FF">
        <td> <div align="left" style="font-size:20px"> <strong> <font color="#000099">步骤③ </font> </strong> </div> </td>
      </tr>
      <tr bgcolor="#E8F3FF">
        <td>为本车次公交添加线路图(不是必需的)&nbsp;&nbsp;&nbsp;
    <input type="button" name="busmap" value="添加图片" onClick="opendiv()"> </td>
      </tr>
      <tr bgcolor="#E8F3FF">
          <td height="20"> <table width="441" border="0" cellspacing="0" cellpadding="0">
              <tr>
                <td width="376"> <div align="center">
                    <input type="button" name="Submit" value="保存车次" onClick="doCheck()">
                  </div> </td>
              </tr>
            </table> </td>
      </tr>
      <tr bgcolor="#E8F3FF">
        <td>&nbsp; </td>
      </tr>
      <tr>
        <td height="20" background="images/bottombg.gif"> </td>
      </tr>
    </table>
    </form>
    </div>
    </body>
    </html>
    修改 删除 举报 引用 回复
    进入用户个人空间
    加为好友
    发送私信
    在线聊天
    发表于:2008-05-12 08:16:226楼 得分:0
    你下面的那个表单没有type=file的元素,不要使用 multipart/form-data,普通的方法即可,你的上传文件不是在上面的那个表单吗
    修改 删除 举报 引用 回复
    进入用户个人空间
    加为好友
    发送私信
    在线聊天
    发表于:2008-05-12 09:46:457楼 得分:0
    额````这样,我试试
    修改 删除 举报 引用 回复

    网站简介广告服务网站地图帮助联系方式诚聘英才English 问题报告
    世纪乐知(北京)网络技术有限公司 版权所有 京 ICP 证 020026 号
    Copyright © 2000-2007, CSDN.NET, All Rights Reserved