|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #78077 move_uploaded_file ignores stream_flush return value of reg. streamWrapper
Submitted: 2019-05-28 09:22 UTC Modified: 2021-08-18 11:10 UTC
Avg. Score:3.7 ± 1.9
Reproduced:2 of 3 (66.7%)
Same Version:0 (0.0%)
Same OS:1 (50.0%)
From: daniel dot pernold at gmail dot com Assigned: cmb (profile)
Status: Duplicate Package: Streams related
PHP Version: 7.2.18 OS: Ubuntu 18.04
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: daniel dot pernold at gmail dot com
New email:
PHP Version: OS:


 [2019-05-28 09:22 UTC] daniel dot pernold at gmail dot com
PHP 7.2.17-0ubuntu0.18.04.1 (cli) (built: Apr 18 2019 14:12:38) ( NTS )

When using `move_uploaded_file` with a stream wrapper url as destination, the return value of the method `stream_flush` is ignored. The function `move_uploaded_file` always returns true, even if `stream_flush` returns false.

Test script:
class MyStreamWrapper

    public function stream_write($data)
        return 1;

    public function stream_flush()
        return false;


stream_wrapper_register('my-wrapper', \MyStreamWrapper::class, 0);
$res = move_uploaded_file($_FILES['uploaded_file']['tmp_name'], 'my-wrapper://' . basename($_FILES['uploaded_file']['name']));
echo $res ? 'true' : 'false';

Expected result:

Actual result:


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2021-07-27 15:48 UTC]
When implicitly flushing on close, the return value is not
checked[1]; that *might* be deliberate, given that almost none of
the implicit flushes checks the return value.

[1] <>
 [2021-08-18 11:10 UTC]
-Status: Open +Status: Duplicate -Assigned To: +Assigned To: cmb
 [2021-08-18 11:10 UTC]
Actually, this is a special case of bug #60110, so I'm closing
this ticket as duplicate.
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Jun 23 03:01:28 2024 UTC