고전적인 asp 및 vbscript를 사용하여 이미지를 저장하고 제목에 오류 메시지가 표시되어야합니다.ADODB.Stream - 인수의 형식이 잘못되었거나 범위를 벗어 났거나 서로 충돌했습니다.
나는 모두 참고 번호로 Base64 Encode String in VBScript과 Convert hex string (image) to base64 (for browser rendering) in VBScript을 사용했지만 운은 아직 없습니다.
내 프로세스는 다음과 같습니다. 나는 html 5 캔버스가 있고 jquery를 사용하여 이미지를 숨겨진 필드에 저장하고 있습니다.
HTML :
<input type="hidden" id="imageData" name="imageData">
JQuery와 :
var image = document.getElementById("canvas").toDataURL("image/png");
image = image.replace('data:image/png;base64,', '');
$('#imageData').val(image);
내가 데이터를 가져 오는, 그리고 난이 image.replace ('데이터 : 이미지/PNG, 64 기수를', '') 제거했습니다 섹션 그게 문제 인 경우. 다음과 같이
내 VBScript 코드는 다음과 같습니다 심지어는 XML DOM 객체없이 변환을 시도
Function SaveFile(imageData)
dim fs,f,mappedpath,filename, userid, fullpathandfilename, imagebinarydata, oStream
userid = 12
filename = Month(now())&"_"&Day(now())&"_"&Year(now())&"_"&Minute(now())&"_"&Second(now())&".png"
mappedpath = Server.MapPath("images/")
fullpathandfilename = mappedpath + "\" + filename
Const adTypeBinary = 1
Const adSaveCreateOverWrite = 2
Set oStream = Server.CreateObject("ADODB.Stream")
oStream.type = adTypeBinary
oStream.open
imagebinarydata = Base64Encode(imageData)
oStream.write imagebinarydata
'Use this form to overwrite a file if it already exists
oStream.savetofile fullpathandfilename, adSaveCreateOverWrite
oStream.close
set oStream = nothing
response.write("success")
End Function
Function Base64Encode(sText)
Dim oXML, oNode
Set oXML = CreateObject("Msxml2.DOMDocument.3.0")
Set oNode = oXML.CreateElement("base64")
oNode.dataType = "bin.base64"
oNode.nodeTypedValue =Stream_StringToBinary(sText)
Base64Encode = oNode.text
Set oNode = Nothing
Set oXML = Nothing
End Function
'Stream_StringToBinary Function
'2003 Antonin Foller, http://www.motobit.com
'Text - string parameter To convert To binary data
Function Stream_StringToBinary(Text)
Const adTypeText = 2
Const adTypeBinary = 1
'Create Stream object
Dim BinaryStream 'As New Stream
Set BinaryStream = CreateObject("ADODB.Stream")
'Specify stream type - we want To save text/string data.
BinaryStream.Type = adTypeText
'Specify charset For the source text (unicode) data.
BinaryStream.CharSet = "us-ascii"
'Open the stream And write text/string data To the object
BinaryStream.Open
BinaryStream.WriteText Text
'Change stream type To binary
BinaryStream.Position = 0
BinaryStream.Type = adTypeBinary
'Ignore first two bytes - sign of
BinaryStream.Position = 0
'Open the stream And get binary data from the object
Stream_StringToBinary = BinaryStream.Read
Set BinaryStream = Nothing
End Function
하지만 다음 줄에서 줄 바꿈에 유지 :
oStream.write의 imagebinarydata
오류 메시지와 함께 :
ADODB.Stream 오류 '800a0bb9'인수는 다음과 같습니다. 잘못된 유형이거나, 허용 범위를 벗어 났거나, 서로 충돌하고 있습니다.
ADODB.Stream을 사용하려면 추가로 설치해야합니까?
레코드를 삽입하고 업데이트하며 제대로 작동하는 다른 부분 (클래식 ASP 및 vbscript 사용)이 있습니다.
해당 폴더에 대한 쓰기 권한이 있습니다.
어떤 아이디어를 찾고 계십니까?
MSGBOX의 VARTYPE (imageData의)를 수행하고 MSGBOX 끝나면 IsArray (imageData의) MSGBOX ISDATE (imageData의) MSGBOX IsEmpty 함수 (imageData의) MSGBOX ISNULL (imagedata) msgbox IsNumeric (imagedata) msgbox IsObject (imagedata)와 imagebinarydata에 대해서도 –
당신은 혼란 스러워요. 당신의 인코딩은'Base64'로 이미지를 보내고 싶지만 [tag : asp-classic] 끝에서 다시 인코딩하려고하지 않는다면, 이미'Base64'가되고 싶습니다. 바이너리입니다. stream (이 때문에'ADODB.Stream'은 인자가 잘못된 타입이라고 불평합니다). 'Base64Encode()'대신'Base64Decode()'를 사용하면 필요한 것을 얻을 수 있습니다. – Lankymart
더 잘 설명 할 답변을 추가했습니다. – Lankymart