CFM scripts not consistently listing contents of folder
$30-100 USD
Cancelled
Posted about 17 years ago
$30-100 USD
Paid on delivery
I upload muliple types of files to the server. Sometimes they are folders, word docs, ppts, pdfs or xls files. There is a script that runs that is supposed to list everything that I have uploaded into a directory. The problem is, it does not work consistently. Sometimes it will display all files, subdirectories, file within, sometimes it will say that nothing is there. I am not sure why it will work with some files/folders, and won't with others. I need to have this work consistently across the site where I use this tool. It may be a permissions problem, I'm not sure...
Here's a sample script that lists the contents of the directory:
<cfinclude template="../usercheck.cfm">
<cfparam name="URL.module" default="">
<cfparam name="URL.file" default="">
<cfparam name="URL.action" default="">
<HTML>
<HEAD>
<TITLE>Title</TITLE>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
<link href="../links.css" rel="stylesheet" type="text/css">
<!-- End Preload Script -->
<style type="text/css">
<!--
.style3 {color: #FFFFFF; font-weight: bold; }
.style6 {font-size: 10px}
-->
</style>
</HEAD>
<BODY BGCOLOR=#FFFFFF LEFTMARGIN=0 TOPMARGIN=0 MARGINWIDTH=0 MARGINHEIGHT=0 ONLOAD="preloadImages();">
<a href="/index.html"><img src="/Images/graphic.gif" width="169" height="84" border="0"></a>
<br>
<cfset pathn = "#getDirectoryFromPath(cgi.PATH_TRANSLATED)#files">
<CFIF ([login to view URL] IS NOT '')>
<CFDIRECTORY ACTION="LIST"
DIRECTORY="#pathn##urldecode([login to view URL])#"
NAME="FileCheck"
FILTER="#URL.file#">
<cfif [login to view URL] eq "Delete">
<CFIF [login to view URL] GT 0>
<cffile file="#pathn##urldecode([login to view URL])##URL.file#" action="delete">
<cflocation url="[login to view URL]([login to view URL])#">
</CFIF>
<cfelse>
<CFIF [login to view URL] GT 0>
<!--- <cfhttp
method="Get"
url="#getdirectoryfrompath(pathn)##URL.file#"
path="#pathn#"
file="#URL.file#"> --->
<CFHEADER
NAME="content-disposition"
VALUE="attachment; filename=#URL.file#">
<CFCONTENT type="application/unknown" file="#pathn##URLdecode([login to view URL])##URL.file#" DeleteFile="No"></CFCONTENT>
</CFIF>
</cfif>
<cfelse>
<CFDIRECTORY ACTION="LIST"
DIRECTORY="#pathn##urldecode([login to view URL])#"
NAME="dirlist">
<table width="487" border="0" align="center">
<tr bgcolor="#004B8D">
<td width="479" height="36"><span class="style3">&nbsp;Physician Modules </span></td>
<td></td>
</tr>
<cfif #dirlist.recordcount# gt 2>
<CFOUTPUT QUERY="dirlist">
<CFIF type IS 'File'>
<tr bordercolor="##D5EBFF" bgcolor="##D5EBFF">
<td width="479" bordercolor="##D5EBFF" bgcolor="##F4FAFF" class="links">
<span class="style6"><a href="#cgi.SCRIPT_NAME#?module=#URLEncodedFormat([login to view URL])#&file=#name#">&nbsp;#left(name,len(name)-4)#</a></span>
</td>
<td width="50" bgcolor="##FFFFFF">
<cfswitch expression="#right(name,3)#">
<cfcase value="xls">
<cfset imagesrc="/Images/excel.gif">
</cfcase>
<cfcase value="pdf">
<cfset imagesrc="/Images/pdf.gif">
</cfcase>
<cfcase value="doc">
<cfset imagesrc="/Images/word.gif">
</cfcase>
<cfcase value="ppt">
<cfset imagesrc="/Images/powerpoint.gif">
</cfcase>
<cfdefaultcase>
<cfset imagesrc="/Images/unknown.gif">
</cfdefaultcase>
</cfswitch>
<div align="center"><img src="#imagesrc#" width="31" height="27"></div>
</td>
</tr>
<cfelseif type eq 'Dir'>
<cfif ((name neq "." ) AND (name neq "..")) >
<cfset tempname = #url.module# & "" & #name#>
<tr bordercolor="##D5EBFF" bgcolor="##D5EBFF">
<td bordercolor="##D5EBFF" bgcolor="##F4FAFF" class="links"><a href="#CGI.SCRIPT_NAME#?module=#URLEncodedformat(tempname)#">#name#</a></td>
<td bgcolor="##FFFFFF" class="links">Directory</td>
</tr>
</cfif>
</cfif>
</cfoutput>
<cfelse><!--- <cfif #dirlist.recordcount# lt 2> --->
<tr bordercolor="#D5EBFF" bgcolor="#D5EBFF">
<td bordercolor="#D5EBFF" bgcolor="#F4FAFF" class="links">
<span class="style6">No Files Found</a></span></td>
<td bgcolor="#FFFFFF">&nbsp;</td>
</tr>
</cfif>
</table>
</cfif>
<table width="100%" border="0" cellpadding="0" cellspacing="0" class="links">
<tr>
<td height="50" align="center" valign="middle" class="links">
<cfinclude template="../navmenu.cfm">
</td>
</tr>
</table>
</BODY>
</HTML>