FTP code

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
jfarissi
Forum Newbie
Posts: 4
Joined: Fri Aug 15, 2008 3:25 am

FTP code

Post by jfarissi »

Hi
When I execute this code in linux console its work fine (all file in the ftp server) while on the firefox browser (linux) that gives nothing .

Code: Select all

#!/usr/bin/php -q
<?php
# set up basic connection
 
$ftp_server = 'alfa.singularweb.com';
 
$conn_id = ftp_connect($ftp_server);
 
 
 
# login with username and password
 
$ftp_user_name = 'tore';
 
$ftp_user_pass = 'tore';
 
 
 
$login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass);
 
 
 
# get contents of the current directory
 
$contents = ftp_nlist($conn_id, ".");
 
 
 
# output $contents
 
print_r($contents);
?>
can you help me.

thanks
alex.barylski
DevNet Evangelist
Posts: 6267
Joined: Tue Dec 21, 2004 5:00 pm
Location: Winnipeg

Re: FTP code

Post by alex.barylski »

I'm not sure I understand the question or problem, but...

If the script connects to an FTP server when invoked from CLI and nothing when invoked from a browser...I would first suspect that maybe it's the shebang line at the start of the script??? Try removing that and see what happens...

Secondly...PHP CLI and Apache are two different executables.

Step through the script when executed through the browser and make sure all appropriate extensions are installed/loaded.
jfarissi
Forum Newbie
Posts: 4
Joined: Fri Aug 15, 2008 3:25 am

Re: FTP code

Post by jfarissi »

hi
in windows system in the browser the code work fine.
under linux the count($contents) = 0

thanks
Post Reply