Cannot list files in a directory

I am using CF 7 and this code does not return any files:

<cfset fileLocation = "\\server\uploader\pass-fail"> <cfdirectory action = "list" directory = fileLocation name = "pass_fail_files" > <cfdump var="#pass_fail_files#" expand="yes" label="files in pass-fail" > <cfoutput>#pass_fail_files.name#</cfoutput> <cfoutput>#pass_fail_files.directory#</cfoutput> <cfoutput>#pass_fail_files.size#</cfoutput> <cfoutput>#pass_fail_files.type#</cfoutput> <cfoutput>#pass_fail_files.dateLastModified#</cfoutput> <cfoutput>#pass_fail_files.attributes#</cfoutput> <cfoutput>#pass_fail_files.mode# </cfoutput> 

I checked that there really were several text files in the directory. But when I run the code, all I get is:

alt text http://img682.imageshack.us/img682/5603/nofiles.png

What am I doing wrong?

+4
source share
3 answers

I just tried this:

 <cfset fileLocation = "\\192.168.8.20\websites"> <cfdirectory action = "list" directory = "#fileLocation#" name = "pass_fail_files" > <cfdump var="#pass_fail_files#" expand="yes" label="files in pass-fail" > 

In CF7, CF8 and Railo, and it works every time.

Please note: I updated your code, so it uses the directory attribute as directory = "#fileLocation #" , not directory = fileLocation .

Trying your code, I never received results, but also did not receive errors. Changing it to use double quotes and hashes did the trick since it stopped using it as a variable.

Hope this helps you.

+7
source

My first question would be, does a ColdFusion service user have read access to a folder?

In fact, I think your code should be

<cfdirectory action = "list" directory = "#fileLocation#" name = "pass_fail_files" >

I think that now you say that you want to look in a directory with the name "fileLocation".

+2
source

Assuming you have done all the latest CF7 updates / patches / patches.

-1
source

Source: https://habr.com/ru/post/1304272/


All Articles