Professional Web Applications Themes

Cfdirectory Problems - Coldfusion - Advanced Techniques

I have the following problem. I am trying to write some code to do the following. I want to display orphaned photos, i.e. that is I want to display all photos in a certain folder who?s filename name isn?t in my database field ?Image? The following code gets all of the files in the Folder named Photos <cfparam name="z" default="" type="Any"> <cfparam name="URL.z" default="" type="Any" > <cfdirectory directory="#Application.UploadPathToPhotos##URL.z# " name="myDirectory" sort="name ASC, size DESC"> <link href="Assets/SmallworldStyleV1.css" rel="stylesheet" type="text/css"> <table width="80%" border="0"> <tr class="DefaultFont"> <td width="20%">Total Orphaned Photos ??</td> <td width="80%">Size</td> </tr> <cfoutput query="myDirectory"> <tr> <td> <img src="#Application.PathToPhotos##URL.z##myDirectory .Name#" width="100" /> ...

  1. #1

    Default Cfdirectory Problems

    I have the following problem.

    I am trying to write some code to do the following.

    I want to display orphaned photos, i.e. that is I want to display all photos
    in a certain folder who?s filename name isn?t in my database field ?Image?

    The following code gets all of the files in the Folder named Photos

    <cfparam name="z" default="" type="Any">
    <cfparam name="URL.z" default="" type="Any" >

    <cfdirectory directory="#Application.UploadPathToPhotos##URL.z# "
    name="myDirectory" sort="name ASC, size DESC">
    <link href="Assets/SmallworldStyleV1.css" rel="stylesheet" type="text/css">

    <table width="80%" border="0">
    <tr class="DefaultFont">
    <td width="20%">Total Orphaned Photos ??</td>
    <td width="80%">Size</td>
    </tr>
    <cfoutput query="myDirectory">
    <tr>
    <td>
    <img src="#Application.PathToPhotos##URL.z##myDirectory .Name#" width="100"
    /> <br>
    <span class="DefaultFont">#myDirectory.Name#</span>
    </td>
    <td class="DefaultFont">
    #myDirectory.Size# kB
    </td>
    </tr>
    </cfoutput>
    </table>

    I need to write something like this to get only the orphaned photos

    <cfquery name="GetOrphanedPhotos" datasource="#Application.dsn#">
    SELECT *
    FROM photo_database
    WHERE Image <> '#myDirectory.Name#'
    </cfquery>

    Is this possible?
    Help would be greatly appreciated.
    Thanks Kris


    wheres Guest

  2. #2

    Default Re: Cfdirectory Problems

    When you output the CFDIRECTORY listing, you can query the database for that
    file name. If you don't find it, it must be orphaned. Something like:

    <cfoutput query="myDirectory">
    <cfquery name="GetOrphan" datasource="#Application.dsn#">
    SELECT Image FROM photo_database
    WHERE Image = '#myDirectory.Name#'
    </cfquery>
    <cfif GetOrphan.recordcount IS 0>
    Image not in database - process any way needed (show name, increment counter,
    etc.)
    </cfif>
    </cfoutput>

    -Paul


    dempster Guest

  3. #3

    Default Re: Cfdirectory Problems

    wheres kris wrote: 

    Hi Kris. Try this:

    WHERE Image not in (#quotedValueList(myDirectory.Name)#)

    christopher.secord@gmail.com Guest

  4. #4

    Default Re: Cfdirectory Problems

    Thanks Dempster for your code,

    It seems to work fine but when i try to display data from the query GetOrphan
    i get nothing.
    the record count part is returning zero aswell when there are orphaned files.
    Any Ideas ?
    Thanks Kris

    Here is my code



    <cfparam name="z" default="" type="Any">
    <cfparam name="URL.z" default="" type="Any" >
    <cfparam name="URL.Image" default="1">

    <cfdirectory directory="#Application.UploadPathToPhotos##URL.z# "
    name="myDirectory" sort="name ASC, size DESC">

    <p>Display Orphaned files ie. Photos that don't belong in a gallery</p>


    <cfoutput query="myDirectory">
    <cfquery name="GetOrphan" datasource="#Application.dsn#">
    SELECT Image FROM photo_database
    WHERE Image = '#myDirectory.Name#'
    </cfquery>
    <cfif GetOrphan.recordcount IS 0>

    <table width="80%">
    <tr>
    <td>
    </td>
    <td>&nbsp; </td>
    </tr>
    <tr>
    <td><img src="#Application.PathToPhotos##GetOrphan.Image#" width="50" />
    <br>
    #myDirectory.Name#</td>
    <td>#myDirectory.Size# kB </td>
    </tr>
    </table>


    </cfif>
    </cfoutput>

    <span class="error">Total of <cfoutput>#GetOrphan.RecordCount#</cfoutput>
    Orphaned Photos</span>

    wheres Guest

Similar Threads

  1. cfdirectory
    By kt03 in forum Coldfusion - Getting Started
    Replies: 3
    Last Post: July 13th, 07:21 AM
  2. CFDIRECTORY
    By majickwolf in forum Macromedia ColdFusion
    Replies: 4
    Last Post: September 13th, 05:15 PM
  3. Problem with cfdirectory
    By qgh in forum Coldfusion - Getting Started
    Replies: 6
    Last Post: July 14th, 06:07 PM
  4. CFDIRECTORY/CFFILE
    By Holmes in forum Macromedia ColdFusion
    Replies: 2
    Last Post: February 20th, 06:51 PM

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
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139