Bug #65701 [Com]: copy() doesn't work when destination filename is created by tempnam()
| From: | haoustc at gmail dot com | Date: | Thu, 10 Oct 2013 02:52:55 +0000 |
| Subject: | Bug #65701 [Com]: copy() doesn't work when destination filename is created by tempnam() | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-182108@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=65701&edit=1
ID: 65701
Comment by: haoustc at gmail dot com
Reported by: flack at contentcontrol-berlin dot de
Summary: copy() doesn't work when destination filename is
created by tempnam()
Status: Open
Type: Bug
Package: *General Issues
Operating System: Ubuntu Linux
PHP Version: 5.5.3
Block user comment: N
Private report: N
New Comment:
that seems a problem.
Previous Comments:
------------------------------------------------------------------------
[2013-09-18 17:54:26] flack at contentcontrol-berlin dot de
Argh, third time's the charm:
file_put_contents($dst, file_get_contents($src))
is working
------------------------------------------------------------------------
[2013-09-18 17:53:00] flack at contentcontrol-berlin dot de
Typo: Should read
file_put_contents($src, file_get_contents($dst))
for the version that works
------------------------------------------------------------------------
[2013-09-18 17:51:33] flack at contentcontrol-berlin dot de
Description:
------------
See the script below. The expected output is
int(4)
instead, I get
int(0)
I tested on the Ubuntu packages for php 5.3.10, 5.4.4 and 5.5.3.
When I use
file_put_contents($src, $dst)
instead of copy(), it works as expected. Also, when I use fopen() and stream_copy_to_stream(). Only
the plain copy() function doesn't behave as expected. Everything is on the same hard disk and
was tested on three different machines (Ubuntu 12.04, 13.04 and Debian 7).
Test script:
---------------
$src = '/tmp/file.txt';
touch ($src);
file_put_contents($src, 'test');
$dst = tempnam('/tmp', 'dst');
copy($src, $dst);
var_dump(filesize($dst));
Expected result:
----------------
int(4)
Actual result:
--------------
int(0)
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=65701&edit=1