Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Andrzejek on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VFP send PDF to URL

Status
Not open for further replies.

FoxAll

Programmer
Jun 13, 2003
49
CA
Hello all,

I have a local VFP9 desktop application monitoring a folder for new PDF file.

I try to send PDF file, from the local VFP9 application to a script on a web server running FoxWeb?

LOCAL PROGRAM :
Code:
	lcFileToSend = FILETOSTR(PDFfile)
oXML=CREATEOBJECT("msxml2.xmlhttp.3.0")
lcLink = "[URL unfurl="true"]http://www.website.com/getpdf.fwx"[/URL]
oXML.Open("POST", lcLink , .f., "", "")
  	
lcFile='<?xml version="1.0"?>'		+ crlf
lcFile=lcFile + "<root>"			+ crlf
lcFile=lcFile + "<Customer>"			+ crlf
lcFile=lcFile + config.customer		   + crlf
lcFile=lcFile + "</Costumer>"			+ crlf
lcFile=lcFile + "<textFileName>"		+ crlf
lcFile=lcFile + lcFullFileName			+ crlf
lcFile=lcFile + "</textFileName>"		+ crlf
lcFile=lcFile + "<textFileRAW>" + lcFileToSend + "</textFileRAW>" + crlf
lcFile=lcFile + "</root>"

lcResult = oXML.Send(lcFile)
lcResult = oXML.responseText

SERVER SITE:
Code:
xmlDoc = CREATEOBJECT("Msxml2.DOMDocument.3.0")
xmlDoc.LoadXML(Request.Form())
lcXML = xmlDoc.XML
lcPDFile=GetInXml(“textFileRAW”)
STRTOFILE(lcPDFile , "receivec.pdf")

...


When I save the file on the server side, and try to open the PDF, it’s empty (blank white PDF page).

When I look at the source of the PDF received and compare it to the original, it’s look like the “CharSet” is different. it's Like a translation as been made from the original.

Can you help me.

thank you
Martin
 
Since PDF is binary and can contain anything, you should not pass over FILETOSTR(PDFfile), but perhaps rather STRCONV(FILETOSTR(PDFfile),13)
On the other end the value between <textFileRAW> and </textFileRAW> then would be decoded on the server side with
lcPDFFile = STRCONV(GetInXML("textFileRAW"),14)

This introduces a 33% overhead but is surely the easiest way to tackle file upload via http POST embedded in the XML you send over.
Technically FTPing files would be better, but you'd give out credentials. That'd only work out, if you can set up an ftp account with read/write access only to the PDF upload folder.

Bye, Olaf.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top