ContentToFile

The ContentToFile method outputs the content of the request to the specified file. The OCX host program must have permission to access this file. Binary (images, pdf files etc) or text data are all OK. This method is specifically optimised for speed.

Syntax

ContentToFile(fileName, overWrite, append)

Parameters

fileName
The fileName to output the contents of the request to
overWrite
Indicates whether to overwrite an existing file with that name if it exists. 1 for overwrite, 0 for no overwrite.
append
Indicates whether to append the contents to the file if it exists, or overwrite. 1 for append, 0 for no append.

Return Values

Empty if successful, otherwise an error message indicating the problem.

Example

The following requests a URL and outputs the content to a file:


<% Set OCXHttp = Server.CreateObject("OCXHTTP.OCXHttpCtrl.1") %>
<% 
result = OCXHttp.GET("http://www.flicks.com/scripts/debug.asp")
%>
<% If  "" = result Then %>

Succesfully requested file.

<% 
saveToFileName = "c:\outputFile.htm"
toFileResult = OCXHttp.ContentToFile(saveToFileName,0,0)
if ("" = toFileResult) Then
	response.Write("Saved to file " & saveToFileName)
else
	response.Write("Could not save to file " & saveToFileName & " error is " & toFileResult)
End if
%>


<% Else %>

Could not request file because: <%= result %>

<% End If %>
 

Applies To

OCXHttp ASP Component