php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #43211 ftp_size() of big files
Submitted: 2007-11-07 12:42 UTC Modified: 2008-11-05 01:00 UTC
Votes:9
Avg. Score:3.9 ± 0.9
Reproduced:9 of 9 (100.0%)
Same Version:7 (77.8%)
Same OS:5 (55.6%)
From: miccots at gmail dot com Assigned:
Status: No Feedback Package: FTP related
PHP Version: 5.2.4 OS: *
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2007-11-07 12:42 UTC] 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


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2008-10-28 13:20 UTC] jani@php.net
Please try using this CVS snapshot:

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

  http://windows.php.net/snapshots/


 [2008-11-05 01:00 UTC] 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".
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Mar 29 14:01:28 2024 UTC