Solved

CFFTP to IIS5 FTP Server Does not List contents of Folders with Long File Names

Posted on 2003-11-21
4
418 Views
Last Modified: 2013-12-24
I have a page I am working on that accesses an FTP server where folders and files have long file names with spaces in them. I need to be able to access them, but when I use the CFFTP command to list the contents of a folder with spaces in the name, it does not return anything. This does not happen with folders that have no spaces in them. I am using Coldfusion MX 6.1 with Dreamweaver MX 2004 on a Windows 2000 Server running the native webserver that comes with Coldfusion (for testing purposes, production server is IIS5).

I stress that this is only a problem with connecting to an IIS FTP server. This does not happen if I am using a FileZilla as my FTP server. I need to use IIS (or something similar) that will use the username/password provided at the FTP login as the authentication for the filesystem, too (any recommendations gladly considered).

My code looks like this (some variables changed to protect internal security, but conventions left the same):

<cfftp
action="listdir"
directory="/Oggs Files/Vacation to the Tarpits/"
name="DirectoryListing"
server="caveserver"
username="pandora\ogg"
password="oogabooga38"
port="22">

<cfoutput query="DirectoryListing">
      #DirectoryListing.Name#
      <br>
</cfoutput>

How do I get it so that it will read folder names that have spaces in it? I have been unable to find anything to help solve the problem all day.

Thanks!

Greg Moore
SRG Partnership Architects
0
Comment
Question by:gregmoore
  • 3
4 Comments
 
LVL 17

Expert Comment

by:anandkp
Comment Utility
Hi use this syntax ... this is what i use & works perfect for me !

<CFFTP CONNECTION="Anand" <!--- give a name to the connection --->
         USERNAME="anonymous" <!--- dont chnage this unless u have given username & passwords --->
         PASSWORD="userName@company.com" <!--- dont chnage this unless u have given username & passwords --->
         SERVER = "192.168.3.38" <!---  IP of teh server from where u wanna read the file --->
         ACTION="Open"
         STOPONERROR="Yes">

<CFIF CFFTP.SUCCEEDED>    
 
    <!--- transfer of the file - Picking up from the FTP server --->
    <CFFTP
      ACTION = "getfile"
      CONNECTION = "Anand"
      LOCALFILE = "D:\akp.htm" <!--- Path where u wanna store the file --->
      REMOTEFILE = "a\New Folder\menu.htm" <!--- a = alias of the FTP server & then the folder path to the file --->
      >  
   
    <CFFTP CONNECTION="Anand"
             ACTION="close"
             STOPONERROR="Yes">
                 
</CFIF>

let me know

K'Rgds
Anand

0
 
LVL 17

Accepted Solution

by:
anandkp earned 500 total points
Comment Utility
& the same logic wld go for listing directories on a FTP server

<CFFTP CONNECTION="Anand" <!--- give a name to the connection --->
      USERNAME="anonymous" <!--- dont chnage this unless u have given username & passwords --->
      PASSWORD="userName@company.com" <!--- dont chnage this unless u have given username & passwords --->
      SERVER = "192.168.3.38" <!---  IP of teh server from where u wanna read the file --->
      ACTION="Open"
      STOPONERROR="Yes">

<CFIF CFFTP.SUCCEEDED>    

      <CFFTP
            ACTION = "ListDir"
            CONNECTION = "Anand"
            DIRECTORY = "a" <!--- a = alias of the FTP server & then the folder path to the file --->
            NAME = "akp">
             
      <CFOUTPUT QUERY="akp">
            #CurrentRow# - #Name#
      </CFOUTPUT>

      <CFFTP CONNECTION="Anand"
            ACTION="close"
            STOPONERROR="Yes">
               
</CFIF>

HTH

K'Rgds
Anand
0
 

Author Comment

by:gregmoore
Comment Utility
Anand,

Thank you for the comments. It did not solve the problem, however. I was still unable to list the contents of folders with long names. I did figure out, through some testing, that I could access those folders if I used the 8.3 naming convention. That wasn't going to work either.

HOWEVER - Your advice did steer me in the right direction: Establishing an FTP connection and then running commands within that connection and then closing the connection when done.

Instead of trying to do the entire directory listing from one cfftp command, I changed the code to open a connection, change the directory, list the contents, and then close the connection.

For some reason, if I change the directory to the long folder name and then list a blank directory, it works like a charm! I guess there's something about listing a specfic directory on IIS that just doesn't work with the cfftp directory= variable and the action="listdir" function.

I used the following strategy, and it seems to have worked:

<!--- Establish FTP Connection --->
      
      <cfftp
      action="open"
      connection="#CurrentSessionID#"  
      server="#ServerName#"
      username="#UserName#"
      password="#Password#"
      port="#PortNo#">
      
<!--- Establish Current Directory --->
      
      <cfftp
      action="changedir"
      connection = "#CurrentSessionID#"
      directory="#URL.CurrentFolder#">

<!--- List Current Directory --->

      <cfftp
      action="listdir"
      connection="#CurrentSessionID#"
      stoponerror="no"
      name="FTPFolderContents"
      Passive="no"
      Directory="">

<!--- Close the Connection --->

      <cfftp action="close" connection="#CurrentSessionID#">

After that, I can run my CFOUTPUT loop and the folders and files come out right!

For your time and leading me in the right direction, I'll give you 1/2 the points!

Thanks again!

Greg
0
 
LVL 17

Expert Comment

by:anandkp
Comment Utility
Its ok ... I am not bothered abt the points

I still wonder abt the long dir names :(
0

Featured Post

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Join & Write a Comment

Suggested Solutions

A web service (http://en.wikipedia.org/wiki/Web_service) is a software related technology that facilitates machine-to-machine interaction over a network. This article helps beginners in creating and consuming a web service using the ColdFusion Ma…
One of the typical problems I have experienced is when you have to move a web server from one hosting site to another. You normally prepare all on the new host, transfer the site, change DNS and cross your fingers hoping all will be ok on new server…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now