SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Member
    Join Date
    Apr 2006
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Showing content of a folder question

    Hi,

    I'm a CF rookie and I have a question for coldfusion gurus.

    I have several files in a folder on the server.
    I would like to show the files on a webpage and make downloadable links.
    The folder has to be dynamically populated because there will be new files in it.

    Any idea how to do that?

    Thanks in advance for your help!

  2. #2
    Take The Blue Pill neilmerton's Avatar
    Join Date
    Jul 2004
    Location
    Leicester, UK
    Posts
    871
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    the following code will look in a folder called 'downloads' and list all the jpg files in alphabetical order.

    Code:
    <cfdirectory directory="#ExpandPath("downloads/")#" name="Downloads" sort="name ASC" filter="*.jpg" />
    
    <cfoutput query="Downloads">
    <a href="download_show.cfm?pic=#Downloads.Name#">View file</a>
    </cfquery>

  3. #3
    SitePoint Member
    Join Date
    Apr 2006
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi again and thanks for your answer!

    If I do this it gives me a blank page. So something has to be wrong here. Please help me out.

    <cfdirectory action="#ExpandPath("downloads/")#" directory="briotest" name="Downloads" sort="name ASC" filter="*.bqy" />

    <cfoutput query="Downloads">
    <a href="download.cfm?pic=#Downloads.Name#">View file</a>
    </cfoutput>

  4. #4
    Take The Blue Pill neilmerton's Avatar
    Join Date
    Jul 2004
    Location
    Leicester, UK
    Posts
    871
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    try changing where you've got action="#ExpandPath("downloads/")#" to action="list" (this is the default action) and alter directory="biotest" to directory="#ExpandPath("biotest/")#". so the new cfdirectory tag should look like:

    <cfdirectory directory="#ExpandPath("biotest/")#" action="list" name="Downloads" sort="name ASC" filter="*.bqy" />

  5. #5
    SitePoint Member
    Join Date
    Apr 2006
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I made this now

    <cfdirectory
    directory="#GetDirectoryFromPath(GetTemplatePath())#"
    name="briotest"
    filter="*.bqy"
    sort="name ASC, size DESC">
    <cftable
    query="briotest"
    htmltable
    colheaders>
    <cfcol
    header="NAME:"
    text="#Name#">
    <cfcol
    header="DOWNLOAD"
    text="#Size#">
    </cftable>


    This works OK now and shows what I want, but how do I integrate links for downloading now?

  6. #6
    Take The Blue Pill neilmerton's Avatar
    Join Date
    Jul 2004
    Location
    Leicester, UK
    Posts
    871
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    i have never used cftable before, but i think the following should work:

    <cfcol
    header="Download"
    text="<a href='download.cfm?id#briotest.name#'>#briotest.name#</a>">


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •