|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2004-10-22 12:18 UTC] wittj at gmx dot net
Description:
------------
On my FTP server I have a file which is about 4GB large. The FTP server (vsftpd) reports the file size correctly (checked with sniffer), however ftp_size() does only return a size of 2147483647 (2^31) bytes. Obviously ftp_size() does not support files larger than that, as I get the same result on other large files.
Reproduce code:
---------------
$conn_id = ftp_connect($server);
$contents = ftp_nlist($conn_id, ".");
foreach($contents as $file) {
print ftp_size($conn_id, $file);
}
Expected result:
----------------
The correct file size
Actual result:
--------------
A file size of 2^31 bytes.
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Wed Oct 29 18:00:01 2025 UTC |
Sorry if I bother you, but I thought that you might be interested in a solution to my problem. I append a patch that transforms ftp_size() to return a float. This works very well for me and is exactly what I was looking for in the first place. I don't know the PHP code well, so this might break everything and make your grandma disappear, but as I said it works well for me and might also be useful to others. I did not notice any inaccuracies, it reports the file size exactly up to the last bit. diff -r php-5.0.2-orig/ext/ftp/ftp.c php-5.0.2/ext/ftp/ftp.c 981c981 < int --- > double 996c996 < return atoi(ftp->inbuf); --- > return atof(ftp->inbuf); diff -r php-5.0.2-orig/ext/ftp/ftp.h php-5.0.2/ext/ftp/ftp.h 180c180 < int ftp_size(ftpbuf_t *ftp, const char *path); --- > double ftp_size(ftpbuf_t *ftp, const char *path); diff -r php-5.0.2-orig/ext/ftp/php_ftp.c php-5.0.2/ext/ftp/php_ftp.c 1037c1037 < /* {{{ proto int ftp_size(resource stream, string filename) --- > /* {{{ proto double ftp_size(resource stream, string filename) 1053c1053 < RETURN_LONG(ftp_size(ftp, file)); --- > RETURN_DOUBLE(ftp_size(ftp, file));