Jump to content

FTP commands


jadeg
Go to solution Solved by jadeg,

Recommended Posts

Did you turn on error reporting? If not, turn it on. If so, what errors are you receiving? Heck, you may be using the commands wrong for all we know, but since you failed to provide a single line of code we would only be guessing.

Edited by Psycho
Link to comment
Share on other sites

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);
?>
Edited by jadeg
Link to comment
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
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
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);
Edited by jazzman1
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.