|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2004-10-21 19:17 UTC] nlopess@php.net
Description:
------------
file_put_contents isn't working with FTP (or I'm doing
something wrong).
Tested in PHP 5.0.3-dev
Reproduce code:
---------------
<?php
$context = stream_context_create(array('ftp' => array('overwrite' => true)));
if(file_put_contents("ftp://anonymous:anonymous@10.1.1.54/MS/OPEN-R/MW/OBJS/SOCROB4L.BIN", file_get_contents('src/SocRob4l.bin'), null, $context) === false) {
echo "There was an error";
} else {
echo "The upload completed succesfully";
}
?>
Expected result:
----------------
The upload completed succesfully
Actual result:
--------------
Warning:
file_put_contents(ftp://...@10.1.1.54/MS/OPEN-R/MW/OBJS/SOCROB4L.BIN):
failed to open stream: Operation now in progress
in /home/socrob4l/consola/update4.php on line 5
There was an error
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Nov 02 00:00:01 2025 UTC |
I've run a strace in the example script and it seems that the server I'm using is very picky. The problem is that PHP logins using multiple packets, and the server isn't expeting that. Output: # strace -e network ./php test.php socket(PF_INET6, SOCK_DGRAM, IPPROTO_IP) = 4 socket(PF_INET, SOCK_STREAM, IPPROTO_IP) = 4 connect(4, {sa_family=AF_INET, sin_port=htons(21), sin_addr=inet_addr("10.1.1.54")}, 16) = -1 EINPROGRESS (Operation now in progress) getsockopt(4, SOL_SOCKET, SO_ERROR, [0], [4]) = 0 recv(4, "220 AIBO FTP Server ready\r\n", 8192, 0) = 27 send(4, "USER ", 5, 0) = 5 send(4, "guest", 5, 0) = 5 send(4, "\r\n", 2, 0) = 2 recv(4, "500 \'GUEST \': command not unders"..., 8192, 0) = 39 Warning:: failed to open stream: Operation now in progress in ..