php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #30516 file_put_contents doesnt work with FTP
Submitted: 2004-10-21 19:17 UTC Modified: 2005-04-04 21:14 UTC
From: nlopess@php.net Assigned:
Status: Not a bug Package: FTP related
PHP Version: 5.0.4 OS: all
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: nlopess@php.net
New email:
PHP Version: OS:

 

 [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 

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-03-07 22:23 UTC] sniper@php.net
Please try using this CVS snapshot:

  http://snaps.php.net/php5-latest.tar.gz
 
For Windows:
 
  http://snaps.php.net/win32/php5-win32-latest.zip

..and again, update the version field accordinly.

 [2005-04-01 19:59 UTC] nlopess@php.net
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 ..
 [2005-04-04 21:14 UTC] sniper@php.net
That's a problem with the FTP server NOT PHP..

 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Oct 08 12:01:26 2024 UTC