0

I've created a module for my client's project that should send a file via FTPS onto a web-service. The web-service allows connection from some IP addresses only.

It works on my localhost, but some FTP-commands don't work on the client's live site.

For example, primarily I connect with ftp_ssl_connect. It works on the client's site.

Then, I log in with ftp_login. It also works on the client's site.

Then, I move to the passive mode with ftp_pasv. It also works on the live site.

But when I'm trying to get the files list with ftp_nlist command, it works on from my localhost but refuses to execute on the client's site.

Also, when I send a file with command ftp_put, it works on my localhost but refuses to work from the client's project.

  $config = yrv_eboks_get_config_data();
  $conn = ftp_ssl_connect($config->ftp_host, 21, 15);
  if (ftp_login($conn, $config->ftp_login, $config->ftp_password)) {
    if (ftp_pasv($conn, true)) {
      $files = ftp_nlist($conn, ".");
      var_dump($files);
    } 
  } else {
    // "Could not login via login via FTPS"
  };

I don't know where is the problem and how to solve it.

Could you advise me, where can be the problem and what to do?

Yakimkin Roman
  • 277
  • 1
  • 2
  • 11

1 Answers1

1
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);

write this at the top of the file and access the php file your browser will display the error. are you sure these functions are enabled on your hosting? because shared server disable lots of function to prevent abuse for example source, symlink, ftp_put etc. You can check which function is disabled by creating a phpfile using below code

<?php
phpinfo();
?>

save the above code as anyname.php then access it and you will see php information there. press ctrl+f (search) button and write disable_functions and there you will see all the disabled functions or create a file with the below code and access it from browser ( it may not work if your provider blocked ini_get function too)

<?php echo "Disabled functions: ".ini_get('disable_functions')."\n"; ?>

if your function is disabled you can enable them by creating php.ini file in your directory or request your hosting provider to enable them.

to enable function: create php.ini with following code

disable_functions = ""

however it may not works if your hosting environment is use default php.ini with priority so better contact with provider and request them to enable.

S M Jobayer Alam
  • 241
  • 1
  • 10