This method allows you send large files to the client without having to use Response.Write() to load these files into a string in Visual FoxPro.

This method can get around the 16 meg limitation of Visual FoxPro strings for request output in COM mode. TransmitFile is much more efficient at sending large files as it avoids loading both FoxPro and the ISAPI DLL with these large strings, but instead causes wc.dll to read output directly from file back to the client.

You can send files directly:

FUNCTION TransmitFile



Or you can generate output dynamically using a separate Response object that writes to file (or any other mechanism that writes a file for that matter) like wwResponseFile.

LOCAL lcOutputFile, loResponse

lcOutputFile = Server.oConfig.oWwDemo.cHtmlPagePath + ;
               "temp\" + SYS(2015) + ".htm"

*** Create a separate response object
loResponse = CREATEOBJECT("wwResponseFile",lcOutputFile)

FOR x=1 TO 1000000
   loResponse.Write("012345678901234567890" + "<br>")

*** Release and close
loResponse = .null.

Response.TransmitFile(lcOutputFile,"text/html") *** Some housekeepingDeleteFiles(JustPath( lcOutputFile ) + "\_*.*",900)  && timeout in 15 minutes






Since wc.dll handles the sending of the file the file access security requirements are important. wc.dll will revert to the underlying system account running the Web Connection application. This will typically be SYSTEM (in IIS5 and earlier) or whatever account you have set up in the IIS 6 or later Application Pool impersonation. Make sure you write/place the output file in a location where this account can read from it.

This method makes it much more feasible to build a file management by authorization scheme like paid access management, as it removes almost completely the load from the Web Connection server instances and only has ISAPI streaming the data back which is very efficient.

Make sure to NOT delete the file you are sending. If you need to delete the files after sending look into using wwUtils::DeleteFiles which allows you to do delayed cleanup.

See also:

Class wwResponse | wwUtils::DeleteFiles | wwResponse::DownloadFile

© West Wind Technologies, 1996-2024 • Updated: 11/26/15
Comment or report problem with topic