-
1. Re: Link to a File
Dan Bracuk Jan 28, 2010 9:16 AM (in response to kodemonki)Filenames will act as a string unless you do something to prevent it. For what you are attempting, you might have problems with files that contain spaces in the name.
-
2. Re: Link to a File
kodemonki Jan 28, 2010 9:18 AM (in response to Dan Bracuk)Thanks Dan.
There are no spaces in the filename, they are in the format #AlphaNumericCode#_Scrap_#integer#_DPL_yyyymmddhhmiss.ext
-
3. Re: Link to a File
ilssac Jan 28, 2010 10:01 AM (in response to kodemonki)Where is the directory you are listing files from?
How does this directory relate to your web root?
If the directory is somehow related to your web root, i.e. directly under it or connected with some type of alias or virtural directory, then you should just be able to provide a URL path to the desired file in the href property of an <a>nchor tag.
If the directory is not accessabile through the web root, then you would need to deliver the file content. This is normally done with the <cfcontent...> tag, but there are other options depending on what exactly you are doing.
I little taste of your code would help greatly.
-
4. Re: Link to a File
kodemonki Jan 29, 2010 11:46 AM (in response to ilssac)The directory I am listing files from is the same of the page I am listing them on.
I have no problem seeing .cfm files in this directory.
<cfdirectory recurse="yes" directory="#getDirectoryFromPath(getCurrentTemplatePath())#" type="file" name="eg_pipp" action="list">
<cfquery name="files" dbtype="query">
SELECT name, directory
FROM eg_pipp
WHERE name like '#file_start#_%'
</cfquery>
<body>
<cfoutput>
<cfdump var="#eg_pipp#">
</cfoutput>
<cfoutput query="files">
<a href="download.cfm?path=#directory#&file=#name#">#name#</a><br />
</cfoutput>
<cfoutput query="files">
<a href="#name#">#name#</a><br />
</cfoutput>The first link gives me "
Complex object types cannot be converted to simple values." for PDF but the second link works fine. For text files (.txt works fine, but .sql does not) I get the same error for the first link and "Page cannot be found" for the second.
Here is download.cfm:
<cfif isDefined("file")>
<cfset myFile = file>
<!---<cfcontent type="text/plain">
<cfheader name="Content-Disposition" value="attachment;filename=#myFile#">--->
<cflocation url="#path#/#myfile#">
</cfif>If I uncomment lines 3 and 4 I get the source code for the error message output.
-
5. Re: Link to a File
Dan Bracuk Jan 29, 2010 1:00 PM (in response to kodemonki)Is the error occurring on the page with the links or the page with the cfcontent tag?
-
6. Re: Link to a File
kodemonki Jan 29, 2010 1:03 PM (in response to Dan Bracuk)The error is occuring on the page with the cfcontent tag, but even when I try to get directly to the .sql file from the page with the links (without going through download.cfm) I get a 'page cannot be found' message.
-
7. Re: Link to a File
Dan Bracuk Jan 29, 2010 4:08 PM (in response to kodemonki)Troubleshooting step number 1 - look at your data. In this case, cfdump var="#url#">
-
8. Re: Link to a File
kodemonki Feb 1, 2010 8:36 AM (in response to Dan Bracuk)Here is what I get:
struct FILE E0J52_Scrap_1_EOD_20100129143822.pdf PATH C:\Inetpub\wwwroot\portal\manu\ford\eg -
9. Re: Link to a File
Dan Bracuk Feb 1, 2010 9:09 AM (in response to kodemonki)Looks like a forward slash backslash problem. Also, your path is not valid for a cflocation.
-
10. Re: Link to a File
kodemonki Feb 1, 2010 9:20 AM (in response to Dan Bracuk)Well when I take out the path and just use the filename (all the files I'm dealing with are in the same directory) I still get the Complex Object Types Cannot Be Converted to Simple Values.
Dumpnig the URL var for this attempt gives me:
struct FILE E0J52_Scrap_1_EOD_20100129143822.pdf -
11. Re: Link to a File
Dan Bracuk Feb 1, 2010 3:50 PM (in response to kodemonki)Looking at this code, normally, you have the cfheader and cfcontent tags in "not the usual order".
Try playing with those tags, and hard code various file names. Once you get that working you can move on to processing variables.

