#40574 [NoF->Opn]: file_put_contents fails with ftp wrapper

From: Date: Mon, 05 Mar 2007 13:48:52 +0000
Subject: #40574 [NoF->Opn]: file_put_contents fails with ftp wrapper
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-109922@lists.php.net to get a copy of this message
 ID:              40574
 User updated by: arnaud@php.net
 Reported By:     arnaud@php.net
-Status:          No Feedback
+Status:          Open
 Bug Type:        Streams related
 PHP Version:     5.2.1
 New Comment:

Using proftpd with authentication fails

php > $c = stream_context_create(array("ftp" =>
array("overwrite"=>true)));
php > var_dump(file_put_contents("ftp://xx:xx@localhost/data.txt",
"data", 0,  $c));


Warning: file_put_contents(): Only 0 of 4 bytes written, possibly out
of free disk space in php shell code on line 1


Previous Comments:
------------------------------------------------------------------------

[2007-03-01 01:00:00] php-bugs at lists dot php dot net

No feedback was provided for this bug for over a week, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".

------------------------------------------------------------------------

[2007-02-21 13:32:46] tony2001@php.net

<?php
$c = stream_context_create(array("ftp" => array("overwrite"=>true)));
var_dump(file_put_contents("ftp://localhost/upload/data.txt",
"data",
0, $c));
?>
outputs:
int(4)

Check your FTP server?

------------------------------------------------------------------------

[2007-02-21 10:06:48] arnaud@php.net

I've ran an strace, here is the result

strace -e network php ftp.php 
socket(PF_INET, SOCK_STREAM, IPPROTO_IP) = 3
connect(3, {sa_family=AF_INET, sin_port=htons(21),
sin_addr=inet_addr("192.168.20.13")}, 16) = -1 EINPROGRESS (Operation
now in progress)

I'd like to add that using the ftp extension works properly
(ftp_connect(), ftp_login(), ftp_put() sequence)

------------------------------------------------------------------------

[2007-02-21 10:03:58] arnaud@php.net

Description:
------------
The ftp wrapper fails on writing operations. I tried
file_put_contents() with a stream context and overwrite set to true. I
tried using fopen() but it fails.

A file_get_contents() works properly though.

When looking at the network traffic I see the following:
port > ftp [SYN] ...
ftp > port [SYN, ACK] ...
port > ftp [RST] ...

I actually use 5.2.0 but this should not make any difference.

Reproduce code:
---------------
var_dump(file_put_contents('ftp://user:pass@host/test.txt',
'fooo'));
PHP Warning:  file_put_contents(): Only 0 of 4 bytes written, possibly
out of free disk space in php shell code on line 1

Warning: file_put_contents(): Only 0 of 4 bytes written, possibly out
of free disk space in php shell code on line 1

bool(false)

Expected result:
----------------
file created with the string as content.

Actual result:
--------------
Fails.


------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=40574&edit=1


Thread (9 messages)

« previous php.bugs (#109922) next »