Skip to content

FTP with SSL: ftp_fput(): Connection timed out on successful writes #20240

@ionutantohi

Description

@ionutantohi

Description

The following code:

<?php

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

$host = '';
$user = '';
$pass = ''';

$connection = ftp_ssl_connect($host);
ftp_login($connection, $user, $pass);
ftp_pasv($connection, true);
ftp_fput($connection, 'test-upload.txt', fopen(__DIR__ . '/my-file.txt', 'r'), FTP_BINARY);

Resulted in this output:

ftp_fput(): Connection timed out exception

But even the if exception was raised, the file is written successfully on the server.

But I expected this output instead:

no exception

PHP Version

PHP 8.4.13 (cli) (built: Oct  1 2025 20:33:51) (NTS)
Copyright (c) The PHP Group
Built by Debian
Zend Engine v4.4.13, Copyright (c) Zend Technologies
    with Zend OPcache v8.4.13, Copyright (c), by Zend Technologies

and also on

PHP 8.2.29 (cli) (built: Jul  3 2025 13:07:49) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.2.29, Copyright (c) Zend Technologies
    with Zend OPcache v8.2.29, Copyright (c), by Zend Technologies

Operating System

Ubuntu 22.04.3 LTS (GNU/Linux 5.15.0-157-generic x86_64)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions