wwPageResponse::TransmitFile

Allows sending large files directly from disk, bypassing FoxPro processing and instead directly serving the file very efficiently. By doing so you can easily send very large files and bypass FoxPro's 16mb memory limitations and without tying a FoxPro Web Connection instance.

Transmit file serves the file as content that is displayed in the browser if the browser supports an in browser viewer. If you need to download a file and save it explicitly you can use Response.DownloadFile() to download a file and force it to be opened with a Save As File dialog using the same TransmitFile semantics.

You can send files directly using a full path:

FUNCTION SendLogo
Response.TransmitFile("c:\sites\MySite\Images\sailbig.jpg","image/jpeg")
RETURN

or using a site relative virtual path:

FUNCTION SendLogo
Response.TransmitFile("~/images/sailbig.jpg","image/jpeg")
RETURN

You can also generate output dynamically to a file on disk. This is a good use case for the wwResponseFile class:

FUNCTION HugeOutput
LOCAL lcOutputFile, loResponse

*** Translate virtual path to physical path
lcOutputFile = THIS.ResolvePath("~/temp/ + SYS(2015) + ".htm")

*** Create a separate response object that writes to file
loResponse = CREATEOBJECT("wwResponseFile",lcOutputFile)

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

*** Release and close
loResponse = .null.

Response.TransmitFile(lcOutputFile,"text/html")

*** Some housekeeping
DeleteFiles(JustPath( lcOutputFile ) + "\_*.*",900)  && timeout in 15 minutes

ENDFUNC
o.TransmitFile(lcFileName, lcContentType, lcFileDisplayName)

Parameters

lcFileName
The physical file name to return back to the client over HTTP:

c:\inetpub\wwwroot\wconnect\temp\uploadedfile.xls

or a virtual relative path:

~\temp\uploadedfile.xls

Note: If you're using the Web Connection .NET Module the filename specified must be inside of the Web directory tree in order to be downloadable. This means any files from other locations first need to be moved or generated into a Web relative path. With the ISAPI handler the file can live anywhere.

lcContentType
The content type of the file you are sending back to the client. If omitted this.ContentType is used instead.

lcFileDisplayName
Optional - Allows you specify a filename (without a path preferrably ie. Data.xlst) to force the file to present a Save As File open dialog in the browser with that filename preselected to save to. If not specified the browser tries to display the file in the browser if a viewer is configured.


See also:

Class wwPageResponse

© West Wind Technologies, 1996-2021 • Updated: 01/26/21
Comment or report problem with topic