ID:               48607
 User updated by:  karachi at mail dot ru
 Reported By:      karachi at mail dot ru
-Status:           No Feedback
+Status:           Open
 Bug Type:         Streams related
 Operating System: FreeBSD
 PHP Version:      5.2.10
 New Comment:

Where can I save captured ftp data?


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

[2009-08-13 01:00:01] 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".

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

[2009-08-05 21:57:24] j...@php.net

Yes, we really need more info about this.

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

[2009-06-26 20:24:14] sjoerd-php at linuxonly dot nl

Thank you for your bug report.

To further investigate this bug, it would be useful if you can supply
some more information. Specifically, the data sent from and to the FTP
server would be useful. You can obtain this with a sniffer such as
tcpdump or Wireshark or maybe by configuring your FTP server. You would
be looking for something like this:

230 Anonymous access granted, restrictions apply.
SIZE test_file
550 test_file: No such file or directory
EPSV 
229 Entering Extended Passive Mode (|||3110|)
STOR /test_file

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

[2009-06-19 16:37:37] karachi at mail dot ru

Description:
------------
I tried to upload a file to ftp server using ftp wrapper functions.
Sequence of steps are: fopen, fwrite, fclose. Sometimes file uploaded
successfully and sometimes several last bytes of file didn't save.
Server reports in log file that transmission was aborted, but fwrite()
returns "true".
I found that fwrite() doesn't check ftp reply code before exiting.
That's why ftp server can receive QUIT command before it processes data
stored and close data connection as described in RFC 959: "The server
may abort data transfer if the control connections
are closed without command." If I insert sleep(1) between fwrite() and
fclose() everything works as expected.
Ftp server used: ProFTPD 1.3.2

Reproduce code:
---------------
<?php
$host = 'localhost';
$user = 'ftp';
$passwd = 'anonymous';

$f = fopen("/home/user/test/test_file", 'r') or
    die ("Unable to open file");

$context = stream_context_create(
    array(
        "ftp" => array(
            "overwrite" => true
        )
    )
);

$f1 = fopen("ftp://$host/test";, 'wb', false, $context) or
    die("Unable to open the file on ftp");

while ($str = fread($f, 1000))
{
    fwrite($f1, $str) or die("Unable to write");
}

fclose($f1);
fclose($f);
?>

Expected result:
----------------
File is successfully stored on ftp server

Actual result:
--------------
Sometimes end of the file isn't stored. It doesn't depend on the size
of the file.


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


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

Reply via email to