F
F
fapchat2020-04-11 11:39:31
Oracle
fapchat, 2020-04-11 11:39:31

How and is it possible to make php work with ftp without VPS?

php -i

ftp

FTP support => enabled
FTPS support => enabled


5e917d41bd5ac862297410.png
And so I found this code
<?php
class FTPClient
{
    private $connectionId;
    private $loginOk = false;
    private $messageArray = array();

    public function __construct()
    {}

    private function logMessage($message)
    {
        $this->messageArray[] = $message;
    }

    public function connect($server, $ftpUser, $ftpPassword, $isPassive = false)
    {

        // *** Установить основное соединение
        $this->connectionId = ftp_connect($server);

        // *** Логин с именем пользователя и паролем
        $loginResult = ftp_login($this->connectionId, $ftpUser, $ftpPassword);

        // *** Устанавливает пассивный режим вкл/выкл (on/off) (по умолчанию стоит off)
        ftp_pasv($this->connectionId, $isPassive);

        // *** Проверка соединения
        if ((!$this->connectionId) || (!$loginResult)) {
            $this->logMessage('Ошибка подключения по FTP!');
            $this->logMessage('Попытка подключения к  ' . $server . ' для пользователя ' . $ftpUser, true);
            return false;
        } else {
            $this->logMessage('Соединение к ' . $server . ', для пользователя ' . $ftpUser);
            $this->loginOk = true;
            return true;
        }  //... 
  }

// *** Определите свой хостинг, имя пользователя и пароль
define('FTP_HOST', '192.168.1.88');
define('FTP_USER', 'Blimpf');
define('FTP_PASS', 'catfish');

// *** Включите класс
include 'ftp_class.php';

// *** Создайте объект FTP
$ftpObj = new FTPClient();

  
// *** Установите соединение
if ($ftpObj->connect(FTP_HOST, FTP_USER, FTP_PASS)) {
 //...
And even though I have ftp enabled, I don't understand how I should define the FTP_HOST, FTP_USER, FTP_PASS constants to make it all work. On the Internet, they write something about VPS, etc.
And without anything paid, can I somehow test the functions for ftp in php?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
I
idShura, 2019-10-15
@ivandao

Your default date language NLS_DATE_LANGUAGE does not match the one specified in the request, so an error occurs. The language can be explicitly specified in the request, for example:
or change at the session level: You can view the value of the language parameter with the following request
You can convert to timestamp like this:

SELECT cast (TO_DATE('September  11, 2019, 5:02:44 PM', 'MONTH DD, YYYY, HH:MI:SS AM','NLS_DATE_LANGUAGE=AMERICAN') AS TIMESTAMP) FROM DUAL;

N
nokimaro, 2020-04-11
@fapchat

FTP support => enabled

Means that you can connect from PHP to third-party FTP servers. That is, you can make an FTP client in PHP.
Accordingly, FTP_HOST and so on are the data of the server where you are connecting and must know them.
FTP support does not mean that your PHP can act as an FTP server that someone can connect to.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question