Hello All. I've been working on this for a few days now, scouring the internet and this site for some solutions. I need to be able to move a PDF from one ASP server to another ASP server (not client to server) using HTTP POST. FTP is not an option becuase I need a synchronous transaction with an HTTP response from the receiving server. Here's what I have so far.
SENDING SERVER
RECEIVING SERVER
This works great with text files. But when I try it with a PDF, most of the file makes it fine, but parts of it are corrupted. I've tried different binary conversions, request header options, etc.. But I can't find a single simple solution. I feel there's gotta be something simple out there.
Thanks in advance.
ToddWW
SENDING SERVER
Code:
fileName = "c:\temp\testread.pdf"
Set objFso = Server.CreateObject("Scripting.FileSystemObject")
Set theFile = objFso.OpenTextFile(fileName,1,False,0)
strFile = theFile.ReadAll
theFile.Close
Set theFile = Nothing
Set objFso = Nothing
Set objHttp = Server.CreateObject("WinHttp.WinHttprequest.5")
objHttp.Open "POST","[URL unfurl="true"]http://myserver.com/portal/testfiles/test2.asp",False[/URL]
objHttp.Send(strFile)
Response.Write objHttp.ResponseText
Set objHttp = Nothing
RECEIVING SERVER
Code:
binData = Request.BinaryRead(Request.TotalBytes)
FOR i = 1 TO LenB(binData)
strFile = strFile + Chr(AscB(MidB(binData,i,1)))
NEXT
fileName = "c:\temp\testresult2.pdf"
Set objFso = Server.CreateObject("Scripting.FileSystemObject")
Set theFile = objFso.CreateTextFile(fileName,True,False)
theFile.Write(strFile)
theFile.Close
Set theFile = Nothing
Set objFso = Nothing
This works great with text files. But when I try it with a PDF, most of the file makes it fine, but parts of it are corrupted. I've tried different binary conversions, request header options, etc.. But I can't find a single simple solution. I feel there's gotta be something simple out there.
Thanks in advance.
ToddWW