Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

can't list files in a directory

Tags:

coldfusion

I'm using CF 7 and this code is not returning 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 have checked to make sure that the directory indeed has several text files. 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?

like image 813
Anthony Avatar asked Jan 23 '23 10:01

Anthony


2 Answers

I've 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" >

On CF7, CF8 and Railo, and works everytime.

Notice I updated your code so it uses the directory attribute as directory = "#fileLocation#" as opposed to directory = fileLocation.

Trying your code, I never got results, but didn't get errors either. Changing it to use double-quotes and hashes did the trick, as it stopped using it as a variable.

Hope it helps you.

like image 157
Marcos Placona Avatar answered Jan 29 '23 12:01

Marcos Placona


My first question would be, does the ColdFusion Service User have read access on folder?

Actually, I think your code should be

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

I think right now, you're telling it to look in a directory named "fileLocation".

like image 44
Adrian J. Moreno Avatar answered Jan 29 '23 13:01

Adrian J. Moreno