Solved

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

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

Save on storage to protect fatherhood memories

You're the dad who has everything. This Father's Day, make sure your family memories are protected. My Passport Ultra has automatic backup and password protection to keep your cherished photos and videos safe. With up to 3TB, you have plenty of room to hold the adventures ahead.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
php.ini on ipage hosting 12 47
VPN Dedicated IP address question 7 43
Coldfusion Datefield problem 2 96
Moving web servers into a DMZ? 3 46
Have you ever sent email via ColdFusion and thought of tracking this mail to capture the exact date and time when the message was opened ?  If yes, then this article is for you ! First we need a table user_email with columns user_id , email , sub…
Meet the world's only “Transparent Cloud™” from Superb Internet Corporation. Now, you can experience firsthand a cloud platform that consistently outperforms Amazon Web Services (AWS), IBM’s Softlayer, and Microsoft’s Azure when it comes to CPU and …
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
Hi friends,  in this video  I'll show you how new windows 10 user can learn the using of windows 10. Thank you.

911 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

17 Experts available now in Live!

Get 1:1 Help Now