Jump to content

FTP commands


jadeg

Recommended Posts

The files are not on the same file as the script. This is my code so far 

<?php
$ftp_server="eeeproject.host22.com";
$ftp_user_name="user";
$ftp_user_pass="password";
$conn_id = ftp_connect($ftp_server) or die ("Couldn't connect to $ftp_server");
$login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass);
	if($login_result){
	    ftp_chdir($conn_id, "public_html");
            echo ftp_pwd($conn_id);
            $buff= ftp_nlist($conn_id, '.');	
            var_dump($buff);

}
ftp_close($conn_id);
?>
Link to comment
https://forums.phpfreaks.com/topic/287414-ftp-commands/#findComment-1474513
Share on other sites

Most likely this library isn't installed to this version of php. Did you try to turn on error reporting as Psycho suggested above? I believe not. You would also check whether a ftp_connect function exists or not to your current version of laguage:

if(!function_exists('ftp_connect')){
  echo "Not exist";
} else {
  echo "Exists";
}

// to get all defined functions

echo '<pre>'.print_r(get_defined_functions(),true).'</pre>';
Link to comment
https://forums.phpfreaks.com/topic/287414-ftp-commands/#findComment-1474522
Share on other sites

I'm not familiar with this library, however, at a starting point add the following error reporting functions on top of the file. 

<?php
ini_set('display_startup_errors',1);
ini_set('display_errors',1);
error_reporting(-1);
$ftp_server="eeeproject.host22.com";
$ftp_user_name="user";
$ftp_user_pass="password";
$conn_id = ftp_connect($ftp_server) or die ("Couldn't connect to $ftp_server");
$login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass);
    if($login_result){
     ftp_chdir($conn_id, "public_html");
echo ftp_pwd($conn_id);
$buff= ftp_nlist($conn_id, '.');    
var_dump($buff);

}
ftp_close($conn_id);

What OS is the server running?

Link to comment
https://forums.phpfreaks.com/topic/287414-ftp-commands/#findComment-1474566
Share on other sites

Try to set the second parameter of a ftp_nlist function to null or to empty string, both cases work to me (linux server).

$buff= ftp_nlist($conn_id, '');

// or

$buff= ftp_nlist($conn_id, NULL);

You can also turn a passive mode on in case the ftp server required.

 

Try,

<?php
$ftp_server = "eeeproject.host22.com";
$ftp_user_name = "user";
$ftp_user_pass = "password";
$conn_id = ftp_connect($ftp_server) or die("Couldn't connect to $ftp_server");
$login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass);
// turn passive mode to on
ftp_pasv($conn_id, true);
if ($login_result) {
    ftp_chdir($conn_id, "public_html");
    echo ftp_pwd($conn_id);
    $buff = ftp_nlist($conn_id,'.');
    var_dump($buff);
}
ftp_close($conn_id);
Link to comment
https://forums.phpfreaks.com/topic/287414-ftp-commands/#findComment-1474621
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.