У меня проблема с моим скриптом.
Я создал веб-сайт в Infomaniak (Shared host)
PHP-скрипт отправляет файл на удаленный FTP-сервер.
Затем я перешел на другой хост (тоже поделился): Swisscenter.
Это не работает с этого сервера
Это тот же скрипт, с теми же логинами.
На конечном сервере отсутствует белый список IP-адресов
Я тестировал с PHP 5.6 и 7.0, без изменений
Вот ошибка: https://pastebin.com/ZSyVLtsF
Whoops, looks like something went wrong.
1/1
ErrorException in FTP.php line 47:
ftp_put(): Opening data channel for file transfer.
in FTP.php line 47
at HandleExceptions->handleError('2', 'ftp_put(): Opening data channel for file transfer.', '/website/website.ch/src/app/FTPManager/FTP.php', '47', array('remote_file' => 'src/storage/path/test.TXT', 'file' => 'commande/test.TXT'))
at ftp_put(resource, 'commande/test.TXT', 'src/storage/path/test.TXT', '2') in FTP.php line 47
at FTP->upload('src/storage/path/test.TXT', 'commande/test.TXT') in AdminController.php line 174
at AdminController->sendOrderFtp(object(Order)) in AdminController.php line 124
at AdminController->validateOrderPost(object(Request), 'test')
at call_user_func_array(array(object(AdminController), 'validateOrderPost'), array(object(Request), 'id' => 'test')) in Controller.php line 80
at Controller->callAction('validateOrderPost', array(object(Request), 'id' => 'test')) in ControllerDispatcher.php line 146
at ControllerDispatcher->call(object(AdminController), object(Route), 'validateOrderPost') in ControllerDispatcher.php line 94
at ControllerDispatcher->Illuminate\Routing\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 52
at Pipeline->Illuminate\Routing\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 102
at Pipeline->then(object(Closure)) in ControllerDispatcher.php line 96
at ControllerDispatcher->callWithinStack(object(AdminController), object(Route), object(Request), 'validateOrderPost') in ControllerDispatcher.php line 54
at ControllerDispatcher->dispatch(object(Route), object(Request), 'App\Http\Controllers\AdminController', 'validateOrderPost') in Route.php line 174
at Route->runController(object(Request)) in Route.php line 140
at Route->run(object(Request)) in Router.php line 724
at Router->Illuminate\Routing\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 52
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in AuthenticateWithBasicAuth.php line 38
at AuthenticateWithBasicAuth->handle(object(Request), object(Closure))
at call_user_func_array(array(object(AuthenticateWithBasicAuth), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 136
at Pipeline->Illuminate\Pipeline\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 32
at Pipeline->Illuminate\Routing\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 102
at Pipeline->then(object(Closure)) in Router.php line 726
at Router->runRouteWithinStack(object(Route), object(Request)) in Router.php line 699
at Router->dispatchToRoute(object(Request)) in Router.php line 675
at Router->dispatch(object(Request)) in Kernel.php line 246
at Kernel->Illuminate\Foundation\Http\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 52
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in ViewFiller.php line 37
at ViewFiller->handle(object(Request), object(Closure))
at call_user_func_array(array(object(ViewFiller), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 136
at Pipeline->Illuminate\Pipeline\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 32
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in StartSession.php line 64
at StartSession->handle(object(Request), object(Closure))
at call_user_func_array(array(object(StartSession), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 136
at Pipeline->Illuminate\Pipeline\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 32
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in Language.php line 36
at Language->handle(object(Request), object(Closure))
at call_user_func_array(array(object(Language), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 136
at Pipeline->Illuminate\Pipeline\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 32
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in CheckForMaintenanceMode.php line 44
at CheckForMaintenanceMode->handle(object(Request), object(Closure))
at call_user_func_array(array(object(CheckForMaintenanceMode), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 136
at Pipeline->Illuminate\Pipeline\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 32
at Pipeline->Illuminate\Routing\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 102
at Pipeline->then(object(Closure)) in Kernel.php line 132
at Kernel->sendRequestThroughRouter(object(Request)) in Kernel.php line 99
at Kernel->handle(object(Request)) in index.php line 53
Я не понимаю, почему это работает на первом хосте, а не на втором
Любая идея ?
Спасибо
UPDATE
Вот класс PHP для FTP:
namespace App\FTPManager;
class FTP
{
protected $host;
protected $port;
protected $timeout;
protected $connection;
protected $mode = FTP_BINARY;// FTP_ASCII;
public function __construct($host, $port = 21, $timeout = 90)
{
$this->host = $host;
$this->port = $port;
$this->timeout = $timeout;
}
/**
* @return mixed
*/
public function getConnection()
{
if (!$this->connection) {
$this->connection = ftp_connect($this->host, $this->port, $this->timeout);
}
return $this->connection;
}
public function login($username, $password)
{
return ftp_login($this->getConnection(), $username, $password);
}
public function upload($remote_file, $file)
{
return ftp_put($this->getConnection(), $file, $remote_file, $this->mode);
}
public function download($file, $remote_file)
{
return ftp_get($this->getConnection(), $remote_file, $file, $this->mode);
}
public function close()
{
ftp_close($this->connection);
$this->connection = null;
}
}