Solved

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

Posted on 2003-11-21
4
425 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
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 500 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

Don't miss ATEN at NAB Show April 24-27!

Visit ATEN at NAB Show to learn how our "Seamlessly Entertaining" solutions deliver fast, precise video streaming without delays for the broadcasting and media environment. ATEN will showcase its 16x16 Modular Matrix Switch (VM1600) and KVM Over IP Solution (KE6900 series).

Question has a verified solution.

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

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…
When it comes to showing a 404 error page to your visitors, you do not want that generic page to show, and you especially do not want your hosting provider’s ad error page to show either. In this article, I will show you how to enable the custom 40…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

756 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