#43211 [Opn->Fbk]: ftp_size() of big files
| From: | jani@php.net | Date: | Tue, 28 Oct 2008 13:20:02 +0000 |
| Subject: | #43211 [Opn->Fbk]: ftp_size() of big files | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-130229@lists.php.net to get a copy of this message | ||
ID: 43211
Updated by: jani@php.net
Reported By: miccots at gmail dot com
-Status: Open
+Status: Feedback
Bug Type: FTP related
Operating System: *
PHP Version: 5.2.4
New Comment:
Please try using this CVS snapshot:
http://snaps.php.net/php5.2-latest.tar.gz
For Windows:
http://windows.php.net/snapshots/
Previous Comments:
------------------------------------------------------------------------
[2007-11-07 12:42:40] miccots at gmail dot com
Description:
------------
Hello.
Function ftp_size() woks strange for files which size is mjre then 2^16
bytes.
When checking size after uploading it returns -1. But if close and open
connection it returns the correct result (after sprintf('%u', $size));
So, this function could not determine size of big file until reconnect.
Reproduce code:
---------------
<?php
$start_time = microtime(TRUE);
$ftp_ip = 'ftp_ip';
$local_file = 'local_file.fil';
$remote_file = 'file_1.fil';
$conn = ftp_connect($ftp_ip, 21);
ftp_login($conn, 'anonymous','anonymous@mail.ml');
ftp_pasv($conn, TRUE);
echo "\n Time spent: ".(microtime(TRUE) - $start_time)."s... Trying to
upload ".sprintf('%u', filesize($local_file))." bytes.\n";
echo "\n Time spent: ".(microtime(TRUE) - $start_time)."s... 1st
attempt: ftp_put_returned: ".(ftp_put($conn, $remote_file, $local_file,
FTP_BINARY)?'TRUE':'FALSE')."\n";
echo "\n Time spent: ".(microtime(TRUE) - $start_time)."s... Size of
uploaded file before reconnect: ".sprintf('%u', ftp_size($conn,
$remote_file))." (".ftp_size($conn, $remote_file).") bytes\n";
echo "\nReconnect...\n";
ftp_close($conn);
$conn = ftp_connect($ftp_ip, 21);
ftp_login($conn, 'anonymous','anonymous@mail.ml');
ftp_pasv($conn, TRUE);
echo "\n Time spent: ".(microtime(TRUE) - $start_time)."s... Size of
uploaded file after reconnect: ".sprintf('%u', ftp_size($conn,
$remote_file))." (".ftp_size($conn, $remote_file).") bytes\n";
ftp_close($conn);
?>
Actual result:
--------------
Time spent: 0.01035213470459s... Trying to upload 3532439032 bytes.
Time spent: 0.010672092437744s... 1st attempt: ftp_put_returned:
FALSE
Time spent: 661.11731815338s... Size of uploaded file before
reconnect: 4294967295 (-1) bytes
Reconnect...
Time spent: 661.12095808983s... Size of uploaded file after reconnect:
3532439032 (-762528264) bytes
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=43211&edit=1