cfdirectory list

I want to see the files that are located in a folder on the site.
I have:
"< cfdirectory action ="LIST"directory="D:\websites\mysite.com\www\wrs\#url.id#\ "name ="myDirectory">
< cfdump var = "#myDirectory.name #" >
There is no evidence even if 2 files have been uploaded here.
I did the cfdump & it is said:
[empty string]

Any idea?

Cool.

Quote:
Posted by: Adam Gertz
The fileArray displayed different variables. The part of the index of the table changed the italic police. Be sure to add the index as the first dimension of the array. fileArray [index] [number].

Tags: ColdFusion

Similar Questions

  • I can't get a value from a list of CFDIRECTORY.

    I avoided the madness all these years, but this issue was finally on the brink.  My placement in an institution is in your hands.

    I try to get the name of a specific directory to the list of directories produced by action CFDIRECTORY = 'list '.  But everything I try fails in one way or another.  Bascially, I can't get the value of the structure - even if the code IS the value - because he thinks that the value is meant to be a field or a key.  (The server running CF8).

    These lines of code work fine:

    <!-do and loop through the list of local directories. ->

    < CFSET LocalDirectoryList = "" > "".

    < action CFDIRECTORY = 'list' name = "LocalDirectoryList" TYPE = "dir" directory = "#PathOfLocalFolderToCopyToRemoteFolders #" >

    < CFIF IsDefined("LocalDirectoryList.RecordCount") AND GT LocalDirectoryList.RecordCount '0' >

    < request CFLOOP = "LocalDirectoryList" >

    Now comes the killer.  I want to set a variable whose value is the name of the local current directory - in other words, the value of LocalDirectoryList.Name for each loop the loop.  But if I try to access LocalDirectoryList.Name as a string variable simple, the way I usually for a query string variable-

    < CFSET ThisLocalDirectory = LocalDirectoryList.Name >

    -I get a message "you have attempted to dereference a scalar variable of type class java.lang.String as a structure with members.

    However, if I treat the "LocalDirectoryList.Name" as a structure and try to deconstruct with one of the following conditions.

    (1) < CFSET ThisLocalDirectory = Evaluate (LocalDirectoryList.Name) >

    (2) < CFSET ThisLocalDirectory = ' #Evaluate (LocalDirectoryList.Name) # ">

    (3) < CFSET ThisLocalDirectory = ' #StructFind (LocalDirectoryList, Name) # ">

    (4) < CFSET ThisLocalDirectory = StructFind (LocalDirectoryList, name) >

    (5) < CFSET ThisLocalDirectory = ' #Evaluate (StructFind (LocalDirectoryList, name)) #">".

    I get either "horizons variable is not defined" (for 1 or 2) or "the specified key, backgrounds, does not exist in the structure" (for 3, 4 or 5).

    In this case, the name of this directory is "horizons."  If the value I'm looking for do EXIST in the structure of 'LocalDirectoryList '.  And the code IS that IT is.  But he thinks it is the NAME of a key, rather than the VALUE of the key.

    Note: The addition of the attribute, listInfo = "Name" to the CFDIRECTORY tag limit fields returned, or key, "Name", but LocalDirectoryList.Name is still a structure, and I still get the same results.

    I'll be the next cuckoo in the cuckoo's nest?  Or can you save me and keep me sane?  My fate is in your hands.

    Thank you!

    You don't need the evaluate statement (in fact you probably shouldn't need to use than ever at that time). And inside the loop of your application, you can send all your query without prefix fields.

    When in doubt, empty your query of cfdirectory.

  • Action = list CFDIRECTORY does not

    We use cfdirectory to extract a list of images from a specific directory. The directory to look in is determined by a variable passed in. We build the directory like this:
    < cfset variables.imagedir = "images / #url.imgdir # ' >
    And we use cfdirectory action = list like this:
    < cfdirectory action = "list" directory = "#ExpandPath (variables.imagedir)" # "name ="imagelisting">"

    It works like a charm on our test server, but on the production server, it returns 0 results. If I manually type in the directory it works on the production server so I know the permissions is not a problem. I even did a cfdump of the variable "variables.imagedir" and copied/pasted in the repertoire of cfdirectory attribute and it worked.

    There seems to be a problem using a variable as the directory. Have you ever seen this happen? Any idease?

    Experimental and production are REHL4 with the standard CFMX7 and have permissions and structures of the same directories.

    > I have even made a
    > cfdump of the variable "variables.imagedir" and copied/pasted that in the
    > directory of cfdirectory attribute and it worked.
    >
    > It seems to be a problem using a variable as the directory. Someone at - it
    > never seen this happen? Any idease?

    No, never had a problem using variables in a call to .

    Is it any whitesapce first or last character in the value of your variable? Any
    other weird characters who could not make on a browser, accordingly
    your test of cut-and - paste is invalidated?

    --
    Adam

  • Sort by field of database when using cfdirectory

    I have the following code, but you need to sort the list by a field (sortID) my database (not a value from the directory)

    -How can I add this?

    -J' tried to add "sortID" underneath, but it has no effect?

    -sortID is a field of type varchar 3 digits in MySQL

    <div data-role="collapsible" data-collapsed="true">
        <h3 align="center">Board</h3>
        <ul data-role="listview" data-theme="d" data-inset="true">
          <cfset DirList = "C:\Inetpub\wwwroot\CRM\CCC\attachments\board\">
          <cfset site = ("https://crm.domain.com/crm/ccc/attachments/board/")>
          <cfdirectory directory="#DirList#" name="qDir" action="list" sort="sortID DESC">
          <cfquery dbtype="query" name="dirsOtherOnly">
      SELECT * FROM qDir ORDER BY sortID DESC
      </cfquery>
          <cfoutput>
            <cfloop query="dirsOtherOnly">
              <li>
              <a href="#site##dirsOtherOnly.name#" title="Click to Preview" target="_blank">#dirsOtherOnly.Name#</a>
            </li></cfloop>
         
          </cfoutput>
        </ul>
        <cfif ("sicr" NEQ "region6" AND #Session.kt_login_user# EQ "john" OR #Session.kt_login_user# EQ "bob")>
          <p align="left">Click to add attachment: <cfoutput><a href="ul_l.cfm?id2=500&id5=Board" data-transition="fade" target="_blank">Attachments</a></cfoutput></p>
        </cfif>
      </div>
    
    
    

    Why would you want to order the result set in a column that apparently has nothing to do with it? In all cases, a solution is to get the sortID of the database column and add it to the charly resulting cfdirectory

    Something along these lines

    SELECT sortID

    FROM TBL

    SELECT * FROM qDir

    ORDER BY sortID DESC

  • cfdirectory showing the folders but not files CF11

    I use the example code cfdirectory right of the Adobe still in CF11 site I can't get to show the files in the directory and all files.  Is this perhaps a security setting in CF11?

    The code is pretty basic:

    < cfdirectory directory = "D:/IIS" name = "dirQuery" action = "LIST" >

    <!-get an array of the names of directories. ->

    < cfset dirsArray = arraynew (1) >

    < cfset i = 1 >

    < cfloop query = "dirQuery" >

    < cfif dirQuery.type IS "dir" >

    < cfset dirsArray [i] = dirQuery.name >

    < cfset i = i + 1 >

    < / cfif >

    < / cfloop >

    < cfdump var = "#dirsArray #" >

    < br >

    <!-get-> all in a query of queries directory information.

    < cfquery dbtype = "query" name = "dirsOnly" >

    SELECT * from dirQuery

    WHERE TYPE = "Dir".

    < / cfquery >

    < cfdump var = "" #dirsOnly # ""

    Thank you!

    Gary

    ColdFusion is behaving as expected. By specifying 'dir' as type, tell you it to display only files. If you want to view the files, and then specify the type as "file".

  • &lt; cfdirectory... &gt; his suddenly blind to domain directories.

    All of a sudden this morning this < cfdirectory... > line began to return an empty result set.  When he worked very well all week since I worked on a project.

    <cfdirectory 
         action="list" 
         name="xmlFiles" 
         directory="\\dprhq01\purcurrent$\ppur\" 
         filter="*.xml" 
         recurse="yes" 
         type="file">
    

    Although there are certainly some files to this place and if it connects to the ColdFusion web server using the domain assigned to ColdFusion user can easily access this directory on file server and see the files in windows.

    No exception is thrown, an empty result set is what is returned.

    Some tests showed that file expected results returened to local directories on the web server in ColdFusion, but all calls from remote domain return empty results, even to access the ColdFusion web server through its domain name.

    Any ideas of what else to look for.  We restarted the ColdFusion server a couple of times already and which did not affect the results.

    Thank you

    Ian

    Yes suspended JRun threads that make you think you are stopping and restarting ColdFusion, when in fact you are not.

    Killed processes explore and obtained a clean reboot and issue resloved.

  • Creation of div tags programmatically based on the directory list

    Hey guys,.

    I'm trying to use the javascript BarelyFitz Tabber to classify manual hundreds of use on a page. The user manuals are stored in directories, and I am trying to create tabs for each directory progammatically. No matter how hard I try, I can't seem to find a way to determine whether the function is parsing to a subdirectory of the previous directory or the root directory orginal. Here's some pseudocode:

    At the beginning of the directory parse loop:

    If (currentdirectory is subdir)

    {

    If (no tab container)

    {

    Add tab container (div)

    Add a tab (div)

    }

    on the other

    {

    Add a tab

    }

    }

    on the other

    {

    List of files

    }

    After the analysis subdirectory loop:

    If (lastdirectory was a subdirectory of this directory)

    {

    close the div (tab container)

    }

    Here's the CF code:

    <cffunction name="fDirectoryListing" 
        description="Outputs table rows for a directory listing and allows DIRINFO.txt directory name replacement"
        returnType="string"
        output="true">
        
        <cfargument name="MyRoot" type="string" required="true">
        <cfargument name="ThisSub" type="string" required="true">
        <cfargument name="DirDepth" type="numeric" default="0">
        <cfargument name="ShowNoFiles" type="boolean" default="0">
        
        <cfset var qDirectoryList = "">
        <cfset var FileCount = 0>
        <cfset var ThisFullDir = "#MyRoot#\#ThisSub#">
        <cfset var SpaceMultiplier = 20>
        <cfset var Indent = SpaceMultiplier * DirDepth>
        <cfset var rootDir = 0>
        <cfset var nested = false>
    
    <cfdirectory action="LIST" directory="#ThisFullDir#" name="qDirectoryList" sort="type ASC, name asc">
    
    <cfoutput>
        <cfloop query="qDirectoryList">
            <CFIF qDirectoryList.type IS "dir">
    <!-- check if this is SubDirectory of root -->
            <cfif rootDir lt DirDepth and not nested>
                <div class="tabber">Start new tabber
                <cfset rootDir = DirDepth>
                <cfset nested = true>
                Nested: #nested# 
            </cfif>
            <cfif rootDir lt DirDepth and nested>
                <cfset nested = false>stop nesting
            </cfif>
            <div class="tabbertab">start tab, DirDepth: #DirDepth# rootDir: #rootDir#
    <!-- end subDir check-->
    
                <cfset ThisDir = "#ThisSub#\#qDirectoryList.name#">
                <cfset DirInfo = "">
                
                <cfif FileExists("#MyRoot#\#ThisDir#\DIRINFO.txt")>
                    <cffile action="READ" file="#MyRoot#\#ThisDir#\DIRINFO.txt" variable="DirInfo">
                <cfelse>
                    <cfset DirInfo = "#qDirectoryList.name#">
                </cfif>
                <img src="../images/blank_bullet.gif" width="#Indent#" height="5"><h2>#DirInfo#</h2>
                #fDirectoryListing(MyRoot, ThisDir, DirDepth+1)#
            <cfelse>
                <cfif qDirectoryList.name is not "DIRINFO.txt">
                    <cfset FileCount = FileCount + 1>
                    <cfif FileCount is 1 and qDirectoryList.currentrow is not 1><br>
                    </cfif>
                    <img src="../images/blank_bullet.gif" width="#Indent#" height="5"><p><a href="GetFile.cfm?ID=#URLEncodedFormat("#ThisSub#\#qDirectoryList.name#")#">#qDirectoryList.name#</a></p>
                    
                </cfif>
            </CFIF>        <cfif nested></div>endnesttab</cfif>
        </cfloop><cfif nested is false>endnestdiv nested: #nested# dirdepth: #DirDepth# rootDir: #rootDir#</div></cfif>
    </cfoutput>
    
    <cfif ShowNoFiles and FileCount is 0>
        <tr><td><img src="../images/blank_bullet.gif" width="#Indent#" height="5"> [ no Files ]</td></tr>
    </cfif>
    
    </cffunction>
    
    

    Any ideas on that?

    Thank you

    Scott

    Whenever I have something like what I did examine the field dirQuery.directory as a bar slash ' / or \ ' delimited list.  The number of items in the list, it's the depth of the directory comes from the root.

    I.E. #ListLen(dirQuery.directory, '/\") #

  • Size of files format CFDIRECTORY

    Hello. I pulled out the size of the files in a list of < cfdirectory > I use, and it shows in bytes. Is there a way to make sure if it is more than 1024 bytes, it shows 1 KB (or whatever is the appropriate size is 1,2,) and in MB exceeding 1024 KB and so on... The files will get larger, and I won't be out of extremely large file sizes.

    Thank you!

    Just calculate them.


       

  • cfdirectory does not... a little

    I hope someone can help me with this. Current CF8 to run on Windows install MultiServer, develop locally on XP Pro and production on Win2003 Server. For some reason, I can't cfdirectory to return results beyond the top-level folders.
    < cfdirectory action = directory "list" = "\\#server#\home\" name = "dircontent" > work and return the results
    < cfdirectory action = directory "list" = "\\#server#\home\#user#\" name = "dircontent" > returns zero results

    I have the service in place to log in with a valid user account. The same thing happens when I try with the other top-level folders, but locally, it will display all correct. Has anyone seen this happen before?

    I realized what it was. Both my CF servers are set up as a MultiServer, but on my local machine I don't bother to install and start a separate JRun service for her, instead let it flow service CFusion. It's that I had put to log on with a valid user account. He has not apparently like that. When I put the file cfm on the instance of 8300 it worked. Even when I started another JRun service to port 8301.

    I don't have a lot of experience working with instance multiserver CF8, but I find it strange that it worked that way. I was expecting cfdirectory function properly if it showed the top-level folders. Well, problem solved.

    Thank you

  • cfdirectory style

    Hi all, I am using the cfdirectory tag to display the contents of a folder, however, I can style fonts, etc etc, but no matter, I do the page seems to want to list the files in a way 'centered', which looks like a mess - y at - it something I'm missing or a tag that must be added to cfdirectory?

    Thanks in advance

    resolved - a my page generation and the styles that were the issue. I'm sorry.

  • Accessed date with cfdirectory

    Is there a way to recover the "access Date" using cfdirectory in CF6.1?

    Details:
    I put on level-cleaning of a site for a client, in CF5 to CF6.1 (for now)
    There are 4 k + files FC, of whom many are nominated "copy to...". ' or 'act_fileName1, 2, 3... ". cfm', and many others have been copied to another directory.
    I need determine what files are actually used.
    My plan is to "touch" the files, the definition date access to 1/1/2007 13:00 ' and testers have run through the site.
    Would tell me what files are actually used, but I would use cfdirectory to list these files for me.

    I'm open to alternative suggestions.

    That would have taken too long. I came up with this:

    C:\Inetpub\Wwwroot>ls - Rutla > files.txt

    With a small violin of RegEx, I can get my list.

  • CFDIRECTORY and DELETE - makes me very angry

    I use a Coldfusion version where there is no recursive = "Yes" options on cffile or cfdirectory. What I've done, it is write my own recursive function that deletes all files in a folder with several subfolders. Completely them wipe it. It's a thing of beauty. Doing this, I create a table of folders and subfolders so that once all the file deletion is made, I can try to run through the folders (most under subfolders first, of course) and try to delete. I am on the first, but then I thought that the next case 'up' (one who had just successfully deleted file under inside) cannot be deleted because it is not supposed to be empty, which is a bloody, dirty lie.

    Any suggestions?

    Figured it out. Instead of delete files that I recursively drill down through the folder structure, I have now just make a list of directories as if I was before. After getting through all directories, I loop on my list - starting with the slot most of the sub files - remove all files in the folder, I work with, then delete the file immediately afterwards. Adam post made me think this. Thanks Adam.

  • CFDIRECTORY - filtering of images

    I have a dating web site where the database contains a field indicating the sex of a Member; 1 male, 2 for the female. How can I get a list of all the images using cfdirectory to men only or women only? Thank you!

    Obviously, cfdirectory has no idea if your member is M or F or which
    the image belongs to which Member, only your done db...
    Thus, at t is your friend:
    (a) get all images with cfdirectory
    (b) select the necessary records in db - db you must have a field for the
    name of the image file that will be compared to the results of the query cfdirectory
    (c) QoQ to combine 2 queries and select only the images of M or F

    example of code to select all the images of M members:


    SELECT imageid, imagefilename, sex
    Images
    WHERE sex = am'


    SELECT *.
    OF dirQuery, dbQuery
    WHERE dirQuery.name = dbQuery.imagefilename

    HTH

    Azadi Saryev
    SABAI - Dee.com
    http://www.SABAI-Dee.com/

  • cfdirectory to network locations

    The long-term goal is to be able to use cffile to write text files to different servers and I am trying to understand the syntax with cfdirectory. Here's the code.

    < cfset thedir 'something' = >
    < cfdirectory directory = "" #thedir # "name = 'x' action 'list' = >"
    < cfdump var = "#x #" >

    In the first set, if I set the variable what whether that looks like "drive_letter\directory\subdirectroy\etc", I see the contents of the directory. So far so good.

    The problem is, whenever I have something else, I get nothing. Some of my failed attempts include:

    http://server_name/directory/
    http://ip_address/directory/
    as stated above without http:
    \\server_name\directory\
    \\ip_address\directory

    I'm looking for something that is still possible? If it is possible, is my lack of success because of my code, or because of permissions?

    It will definitely be a permissions thing. Default FC (on windows) runs under the system user who has no privileges on a network. It's a pretty easy problem to fix - assuming that your CF server and the servers that you want to access are in the same domain (or forest) then you simply change your CF service starts as a domain user and then give this new authorisation of user account for your local websites as well as your files (and actions).

  • CF8 - CFDIRECTORY

    I have a CFDIRECTORY tag which should be pulling files from another server.

    "< directory="\\#server_name#\users\#client.current_user#\ cfdirectory "action ="list"name ="myDocumentList">

    He worked before install us CF8. I fly over the program to another server that is running CF7 and files are returned very well. There was some change in CF8 I have to do to get it working? It doesn't give me any errors, he don't come back with the info. Anyone else see this problem.

    Thank you

    BJ


    I had not the service is running under the correct user. I corrected which and it works. Thank you Raymond for help.

    BJ

Maybe you are looking for