ftp-deployment icon indicating copy to clipboard operation
ftp-deployment copied to clipboard

Cannot upload file with ftps on PHP7

Open janedbal opened this issue 8 years ago • 12 comments

After update to PHP7 on Windows I tried to use ftps instead of ftp protocol since openssl is bundled in php, but deployment with ftps protocol doesn't work as expected.

If I run deployment via ftp, it works normally:

Loaded remote .htdeployment file
Scanning files in ...
Ignoring ....
Creating remote file .htdeployment.running

Uploading:
...

But if I run it with ftps i get strange error Error: Ok to send data. Also, the log falsely says that remote .htdeployment does not exist. File .htdeployment.running is created.

Remote .htdeployment file not found
Scanning files in ...
Ignoring ...
Creating remote file .htdeployment.running 
Error: Cannot upload file C:\Users\...\AppData\Local\Temp\deployment\dep189C.tmp, number of retries exceeded. Error: Ok to send data.

PHP 7.0.8, ftp-deployment 2.5, Wedos hosting

janedbal avatar May 24 '16 19:05 janedbal

@dg Any hints what should I try to help resolve this issue?

janedbal avatar Jul 10 '16 17:07 janedbal

It seems that ftp in PHP doesn't work with Wedos. I am unable to list files via

$f = ftp_ssl_connect('12345.w71.wedos.net');
ftp_login($f, 'user', 'password');
var_dump(ftp_nlist($f, '*'));  

ftp_connect works fine.

dg avatar Jul 12 '16 12:07 dg

Actually, this is more PHP problem than Wedos problem. After contacting their support I found that they require SSL session reuse, which is not implemented in PHP. Similar problem reported as PHP bug 70195


How to reproduce:

set_error_handler(function ($severity, $message) {
    echo $message;
});

$f = ftp_ssl_connect('12345.w91.wedos.net');
ftp_login($f, 'user', 'pass');
ftp_pasv($f, TRUE);
ftp_fput($f, 'file', fopen(__DIR__ . '/file', 'r'), FTP_BINARY);
ftp_fput(): SSL connection failed; session reuse required: see require_ssl_reuse option in vsftpd.conf man page`

janedbal avatar Jul 19 '16 17:07 janedbal

@dg So if you don't want to use alternative ftp client implementation, we can close this issue...


edit: Or maybe there might be some better error when this occurs.

janedbal avatar Jul 26 '16 08:07 janedbal

Do you know alternative client?

ad better error: it is good idea, can you send PR?

dg avatar Jul 27 '16 13:07 dg

The only one client which uses sockets I found is ngyuki/php-ftp-client, but it doesn't support ftps.

I'll try to find some time to send PR.

janedbal avatar Jul 31 '16 08:07 janedbal

FYI, SSL session reuse will be added to PHP 7.1 and 5.6.26.

OndraM avatar Sep 08 '16 21:09 OndraM

Great, so closing.

dg avatar Sep 08 '16 21:09 dg

$ php -v PHP 7.1.1 (cli) (built: Jan 18 2017 18:50:48) ( NTS MSVC14 (Visual C++ 2015) x86 ) Copyright (c) 1997-2017 The PHP Group Zend Engine v3.1.0, Copyright (c) 1998-2017 Zend Technologies with blackfire v1.16.2~win-x32-non_zts71, https://blackfire.io, by Blackfireio Inc.

i have still same problem with this settings :(

matak avatar May 11 '17 12:05 matak

Still same problem with PHP 7.2.3

dg avatar Mar 07 '18 17:03 dg

Hi all,

Have You someone solved this ??? I have same problém and in version 7.1.17

krystofklima avatar Feb 15 '20 01:02 krystofklima

Hi all,

check if your temp folder exist. My was deleted and ftp_nlist returns bool(false).. I created it again and now it is ok.

TheTEXcz avatar Jun 03 '21 13:06 TheTEXcz