今天遇到了已个很大的问题。
很人是js的新手,在做已个asp的站点。
我通过表单传上来的图片,在其前后都有一些其他的数据。
所以想编辑Request.BinaryRead的返回值。
删除图片数据后面的信息可以通过Request.BinaryRead(Request.TotalBytes-38);
来解决,可是前面的数据就不知道怎么解决了,
我尝试把类型转换成字符串,可是不行,一转就没有了数据。
服务器也不提供ADO Steam对象。
望高手指点!

解决方案 »

  1.   

    用 DOM
    Function BytesFromHexString(strHex)
    With CreateObject("MSXML2.DOMDocument").createElement("e")
    .dataType = "bin.hex"
    .text = strHex;
    BytesFromHexString = .nodeTypedValue;
    End With
    End Function
    Function ToHexString(bytes)
    With CreateObject("MSXML2.DOMDocument").createElement("e")
    .dataType = "bin.hex"
    .nodeTypedValue = bytes;
    ToHexString = .text;
    End With
    End Function
    可 byte 数组和字符串 互相转换使用 ToHexString 时,bytes 中 每字节将被编成二位十六进制 字符。
    1.先将 bytes 转换为 string
    2.使用常规方法,拼切或修改 string 内容
    3.把 string 转换回字节数组
      

  2.   

    我用的是javascript

    我不会vbscript.....
      

  3.   

    不会vb能写asp?
    asp就是vb……
      

  4.   

    jscript 仍然是一样的用法<%
    function bytesFromHexString(strHex) {
        with (Server.CreateObject("MSXML2.DOMDocument").createElement("e")) {
            dataType = "bin.hex";
            text = strHex;
            return nodeTypedValue;
        }
    }function toHexString(bytes) {
        with (CreateObject("MSXML2.DOMDocument").createElement("e")) {
            dataType = "bin.hex";
            nodeTypedValue = bytes;
            return text;
        }
    }
    %>
      

  5.   

    更正一下: toHexString 里 Server.CreateObject---------------------
    另外,上面 VBScript 也错误的使用了 ; 分号