Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2003-11-21
4
Medium Priority
?
429 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
4 Comments
 
LVL 17

Expert Comment

by:anandkp
ID: 9801698
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 1000 total points
ID: 9801718
& 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
ID: 9813275
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
ID: 9815617
Its ok ... I am not bothered abt the points

I still wonder abt the long dir names :(
0

Featured Post

Building an interactive eFuture classroom

Watch and learn how ATEN provided a total control system solution including seamless switching matrix switch, HDBaseT extenders, PDU, lighting control to build an interactive eFuture classroom.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Most ColdFusion developers get confused between the CFSet, Duplicate, and Structcopy methods of copying a Structure, especially which one to use when. This Article will explain the differences in the approaches with examples; therefore, after readin…
Periodically we have to update or add SSL certificates for customers. Depending upon your hosting plan you may be responsible for the installation and/or key generation. In the wake of Heartbleed many sites were forced to re-key. We will concen…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…

705 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