file attribute: Do not specify the directory path in this attribute; use the path attribute.
Try separating the file name and path:
<cfhttp url="http://www.somesite.com/path/testFile.pdf" method="get" getAsBinary="yes" path="c:/test/" file="testFile.pdf"/> <cfheader name="Content-Disposition" value="attachment; filename=myFile.pdf" /> <cfcontent type="application/pdf" file="c:/test/testFile.pdf" />
For small files, you can skip the temp file and use <cfcontent variable..>
<cfhttp url="http://download.macromedia.com/pub/documentation/en/coldfusion/mx7/cfmx7_cfml_qref.pdf" method="get" getAsBinary="yes" /> <cfheader name="Content-Disposition" value="attachment; filename=myFile.pdf" /> <cfcontent type="application/pdf" variable="#cfhttp.fileContent#" />
Update: Dynamic example using a temporary file
<cfset tempDir = getTempDirectory() /> <cfset tempFile = getFileFromPath(getTempFile(tempDir, "testfile")) /> <cfhttp url="http://download.macromedia.com/pub/documentation/en/coldfusion/mx7/cfmx7_cfml_qref.pdf" method="get" getAsBinary="yes" path="#tempDir#" file="#tempFile#" /> <cfheader name="Content-Disposition" value="attachment; filename=myFile.pdf" /> <cfcontent type="application/pdf" file="#tempDir#/#tempFile#" />
Leigh
source share