我尝试发布base64代码保存为图片,但在尝试提交base64代码时,我无法发布文本框的值。
是否有限制通过发布表单发送给代码?
由于无法获得以下文本框的值,我收到错误:
ADODB.Stream错误' 800a0bb9'
参数类型错误,超出可接受的范围,或彼此冲突。
我的HTML代码
<form method="POST" action="?X=1" id="myForm">
<input type="text" name="img_val" id="img_val" value="" />
<input type="submit" value="Submit Largest Code" />
</form>
我的ASP代码:
<%
IF LEN(Request("X"))>0 THEN
base64String = Trim(Request.Form("img_val"))
Set tmpDoc = Server.CreateObject("MSXML2.DomDocument")
Set nodeB64 = tmpDoc.CreateElement("b64")
nodeB64.DataType = "bin.base64"
nodeB64.Text = Mid(base64String, InStr(base64String, ",") + 1)
set bStream = server.CreateObject("ADODB.stream")
bStream.type = 1
call bStream.Open()
call bStream.Write(nodeB64.NodeTypedValue)
caminho=Server.MapPath("/SS/imagem.png")
call bStream.SaveToFile(caminho, 2)
call bStream.close()
set bStream = nothing
END IF
%>
示例Base64:
data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAB4AAAAQFCAYAAABQN9UwAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAP+6SURBVHhe7L0HoCRHde5/Js/Nd6M2Squ8KAsJBUBCIBAYMBgsG3jYgE3yA4PfMzwH3t/P2NgkGz+DbWwwBh4GG7AQYKJkogRCQhIogHJYabU53jh38v98p7pm6vbOzJ2bdu8u30/UdnV1dYVT1bNLf32qEu++Z19dCCGEEEIIIYQQQgghhBBCCCGEHPUkoyMhhBBCCCGEEEIIIYQQQgghhJCjHArAhBBCCCGEEEIIIYQQQgghhBByjEABmBBCCCGEEEIIIYQQQgghhBBCjhEoABNCCCGEEEIIIYQQQgghhBBCyDECBWBCCCGEEEIIIYQQQgghhBBCCDlGoABMCCGEEEIIIYQQQgghhBBCCCHHCBSACSGEEEIIIYQQQgghhBBCCCHkGIECMCGEEEIIIYQQQgghhBBCCCGEHCNQACaEEEIIIYQQQgghhBBCCCGEkGMECsCEEEIIIYQQQgghh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