SunQuest
           FTP Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsSystem AdministrationFTP Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Get inside! Sample the range of functionality easily built with JMSL Library for Time Series Data Analysis, Heat Maps, Portfolio Optimization, Monte Carlo Simulation, Stock Price Charting and more. Download Now!
  #1  
Old August 20th, 2003, 08:20 AM
iwarner iwarner is offline
BrainFreeze
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2000
Location: London
Posts: 318 iwarner User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 h 41 m 9 sec
Reputation Power: 9
Send a message via ICQ to iwarner Send a message via Yahoo to iwarner
Question FTP rawlist issue

Hi,

I have the following code:

PHP Code:
 $ftp_server HOST;
            
$ftp_username USER;
            
$ftp_password PASS';

            IF ($conn_id = ftp_connect($ftp_server))
                {
                IF(ftp_login($conn_id, $ftp_username, $ftp_password))
                    {
                    $dir = ftp_pwd($conn_id);

                    echo $dir; // This returns /

                    // EXAMPLE STRAIGHT FROM THE PHP MANUAL

                    $contents = ftp_nlist($conn_id, $dir);

                    foreach ($contents as $entry) {
                        echo $entry."<br />\n";
                    }
                } 


Now the issue is - that I know there are files in the FTP server and I can connect to it fine - the problem is when I try to list them out I get:

Warning: Variable passed to each() is not an array or object in PAGE on line 198

Using PHP 4.3.2 - when I connect through an FTP client I can see the file fine.

print_r($contents); does not return anything - so it seems that $contents is not receiving the array from ftp_nlist I have tried also ftp_rawlist.

Plz a little bit of guidance with debugging this would be great

E
__________________
_________________________
Triangle Solutions Ltd
http://www.triangle-solutions.com/

Reply With Quote
  #2  
Old August 20th, 2003, 08:34 AM
pprince's Avatar
pprince pprince is offline
Freelance PHP/MySQL Developer
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2003
Location: Bham, UK
Posts: 340 pprince User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 16 h 34 m 21 sec
Reputation Power: 5
sure your FTP client is taking you to eactly the same path? i.e. /

Reply With Quote
  #3  
Old August 20th, 2003, 08:39 AM
iwarner iwarner is offline
BrainFreeze
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2000
Location: London
Posts: 318 iwarner User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 h 41 m 9 sec
Reputation Power: 9
Send a message via ICQ to iwarner Send a message via Yahoo to iwarner
Question I am sure it is?

Here is the session log of WS_FTP LE that I use when I connect to this host.

Now it says - 257 "/" is current directory.

It also goes on about PASSIVE mode and I did try and put this in but that shouldnt make a difference.

PHP Code:
 connecting to IP:21
Connected to IP port 21
220
-MSG
220 ProFTPD 1.2.0pre10 Server 
(CDR/PNC FTPserverAll transfers are logged) [HOST]
USERUSER
331 Password required 
for USER.
PASS (hidden)
230 Anonymous access grantedrestrictions apply.
PWD
257 
"/" is current directory.
SYST
215 UNIX Type
L8
Host type 
(S): UNIX (standard)
PASV
227 Entering Passive Mode 
(195,8,160,71,178,41).
connecting to 195.8.160.71:45609
- -
connecting to 195.8.160.71:45609
Connected to 195.8.160.71 port 45609
LIST
150 Opening ASCII mode data connection for file list
Received 380 bytes in 0.5 secs, (7378.64 bps), transfer succeeded
226 Transfer complete


Reply With Quote
  #4  
Old August 20th, 2003, 08:49 AM
pprince's Avatar
pprince pprince is offline
Freelance PHP/MySQL Developer
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2003
Location: Bham, UK
Posts: 340 pprince User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 16 h 34 m 21 sec
Reputation Power: 5
I've tried it on my ISP's FTP server and it works fine.

Reply With Quote
  #5  
Old August 20th, 2003, 08:54 AM
iwarner iwarner is offline
BrainFreeze
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2000
Location: London
Posts: 318 iwarner User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 h 41 m 9 sec
Reputation Power: 9
Send a message via ICQ to iwarner Send a message via Yahoo to iwarner
Great that helps :)

Can you post the code you wrote - can it be something in php.in I have checked this out also and FTP is enabled.

Anymore takers?

Reply With Quote
  #6  
Old August 20th, 2003, 08:58 AM
pprince's Avatar
pprince pprince is offline
Freelance PHP/MySQL Developer
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2003
Location: Bham, UK
Posts: 340 pprince User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 16 h 34 m 21 sec
Reputation Power: 5
same code just added my ftp host, username and password

here's my output

//httpsdocs
//httpdocs
//error_docs
//cgi-bin
//cert
//anon_ftp
//bin
//conf
//logs
//pd
//web_users
//webstat
//webstat-ssl
//ftpstat

Reply With Quote
  #7  
Old August 20th, 2003, 09:00 AM
pprince's Avatar
pprince pprince is offline
Freelance PHP/MySQL Developer
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2003
Location: Bham, UK
Posts: 340 pprince User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 16 h 34 m 21 sec
Reputation Power: 5
just before the foreach loop add:

echo $contents;

and tell me what it says, it shoulds say array()

Reply With Quote
  #8  
Old August 20th, 2003, 09:05 AM
iwarner iwarner is offline
BrainFreeze
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2000
Location: London
Posts: 318 iwarner User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 h 41 m 9 sec
Reputation Power: 9
Send a message via ICQ to iwarner Send a message via Yahoo to iwarner
Yeah thats what I said I did I used - print_r($contents);

No luck so it seems it is not finding anything I have tried my own server also and different paths but NADA - must be something simple

E

Reply With Quote
  #9  
Old August 20th, 2003, 09:14 AM
iwarner iwarner is offline
BrainFreeze
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2000
Location: London
Posts: 318 iwarner User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 h 41 m 9 sec
Reputation Power: 9
Send a message via ICQ to iwarner Send a message via Yahoo to iwarner
BTW I just tested it on my server and it works - so the code is not at fault - it is something to do with connecting from my local machine that is having an effect - not I can use a client and connect ok I am not behind a proxy or anything so whats the trick?

Reply With Quote
  #10  
Old August 20th, 2003, 09:15 AM
pprince's Avatar
pprince pprince is offline
Freelance PHP/MySQL Developer
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2003
Location: Bham, UK
Posts: 340 pprince User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 16 h 34 m 21 sec
Reputation Power: 5
my thoughts

your code is ok, it works for me
getting nothing with print_r($contents); suggests its finding nothing in the path, hence not creating the array, which will give your foreach() error.

I believe you have a path problem.

Reply With Quote
  #11  
Old August 20th, 2003, 09:21 AM
iwarner iwarner is offline
BrainFreeze
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2000
Location: London
Posts: 318 iwarner User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 h 41 m 9 sec
Reputation Power: 9
Send a message via ICQ to iwarner Send a message via Yahoo to iwarner
Thing is I can connect to the FTP server with my local through PHP fine - but just cant get a listing - so is it the PHP I am using 4.3.2 - what php are you using? My server is an older version?

Reply With Quote
  #12  
Old August 20th, 2003, 09:23 AM
pprince's Avatar
pprince pprince is offline
Freelance PHP/MySQL Developer
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2003
Location: Bham, UK
Posts: 340 pprince User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 16 h 34 m 21 sec
Reputation Power: 5
4.3.1

try putting in an ftp_chdir($conn_id,"/");
just to make sure

Reply With Quote
  #13  
Old August 20th, 2003, 09:27 AM
iwarner iwarner is offline
BrainFreeze
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2000
Location: London
Posts: 318 iwarner User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 h 41 m 9 sec
Reputation Power: 9
Send a message via ICQ to iwarner Send a message via Yahoo to iwarner
did that already no good

Baffled is the word.... can you update your php easily?

Bit lame though blaming that but it may be something in the php.ini?

Reply With Quote
  #14  
Old August 20th, 2003, 09:46 AM
pprince's Avatar
pprince pprince is offline
Freelance PHP/MySQL Developer
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2003
Location: Bham, UK
Posts: 340 pprince User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 16 h 34 m 21 sec
Reputation Power: 5
maybe its your ISP?

Reply With Quote
  #15  
Old August 20th, 2003, 09:48 AM
iwarner iwarner is offline
BrainFreeze
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2000
Location: London
Posts: 318 iwarner User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 h 41 m 9 sec
Reputation Power: 9
Send a message via ICQ to iwarner Send a message via Yahoo to iwarner
I thought that but I can connect through a WSFTP LE - wouldnt the ISP also block that as it is virtually the same thing going on?

But like I said I can connect to the servers just not get an array back with the file listings?

Reply With Quote
Reply

Viewing: Dev Shed ForumsSystem AdministrationFTP Help > FTP rawlist issue


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Linear Mode Linear Mode