Page 1 of 1

FTP code

Posted: Mon Aug 18, 2008 12:45 pm
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

Re: FTP code

Posted: Mon Aug 18, 2008 1:19 pm
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.

Re: FTP code

Posted: Tue Aug 19, 2008 3:13 am
by jfarissi
hi
in windows system in the browser the code work fine.
under linux the count($contents) = 0

thanks