Date:  06/15/2010 05:58:42 AM Msg ID:  004174
From:  Gia Luc Thread:  004172
Subject:  Re: return file with base64 encoding
James, thanks for your input.   I must admit that I've not had problems either, so this is probably a case of worrying over nothing.
If anybody is wondering about the base64 encoder, you can get it from .  It is a VB6 based COM control, and works fine with VFP (I use it with VFP6 all the time). 
Sent by James Williams on 06/14/2010 06:27:54 AM:
I would just use the filetostr() function, I have never had any problems with its conversion and I have used it for PDF's, Word docs, images you name it.
Sent by Gia Luc on 06/10/2010 07:51:33 AM:
I am trying to return a file to the client browser.  To avoid any problems caused by binary to character conversion, I'm not using FILETOSTR().  Instead, I encode the file to base64, then add a http header to say that the file is encoded in base64 and send the file to the browser.
Unfortunately, it does not seem to work properly, the browser simply saves the file as the base64 encoded version, rather than decoding it and then saving the file.  What to do ?  Thanks for any help you can provide.
Here is my code: 
*/' Set up the base64 library in order to encode the file.
oBase64 = createobject("Base64Lib.Base64")

*/' Base64 encode the file to string
lcFileContent = oBase64.EncodeFromFile("c:\transfer\test.pdf")

*/' Specify file name in the http header.
Response.AddHeader("Content-Disposition", "attachment; filename=test.pdf")

*/' Specify size so that the browser's progress bar works properly

*/' Specify the type of encoding used, so the client knows how to decode.

Response.ContentType = "application/pdf"

*/' Send file to browser.

*/' Release the base64 object.