php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #39475 FTP and filesize()
Submitted: 2006-11-12 06:49 UTC Modified: 2006-12-08 07:49 UTC
From: j dot finlay at optusnet dot com dot au Assigned:
Status: Not a bug Package: Documentation problem
PHP Version: Irrelevant OS: Linux
Private report: No CVE-ID: None
 [2006-11-12 06:49 UTC] j dot finlay at optusnet dot com dot au
Description:
------------
According to the documentation, filesize() supports wrappers that also support stat().

This seems to be false with both PHP 5.1.6, and 5.2.1-dev.

Unfortunately this function does not work as expected with FTP URLs. See the reproducable code for an example.

However, the manual states that "As of PHP 5.0.0 this function can also be used with some URL wrappers. Refer to Appendix M, List of Supported Protocols/Wrappers for a listing of which wrappers support stat() family of functionality."

From the manual, in regards to "Appendix M, List of Supported Protocols/Wrappers" in the "FTP and FTPS" section: "Supports stat() No As of PHP 5.0.0: filesize(), filetype(), file_exists(), is_file(), and is_dir() elements only. As of PHP 5.1.0: filemtime()."

Reproduce code:
---------------
<?php
print filesize("http://au2.php.net/distributions/php-5.2.0.tar.bz2")."\n";
?>

Expected result:
----------------
6789838

Actual result:
--------------
Warning: filesize(): stat failed for http://au2.php.net/distributions/php-5.2.0.tar.bz2

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-11-12 06:50 UTC] j dot finlay at optusnet dot com dot au
Changed summary from "HTTP/FTP and filesize()" to just "FTP and filesize()".
 [2006-11-12 07:04 UTC] j dot finlay at optusnet dot com dot au
Originally I thought this was HTTP *and* FTP related, however it seems the manual only mentions FTP supporting stat() so for all intensive purposes, change the URL in my example code to:

ftp://ftp2.au.netbsd.org/pub/php/php-5.1.1.tar.bz2

or something else on an FTP server. My apologies.
 [2006-11-13 19:43 UTC] trickie at gmail dot com
Works for me:

PHP 5.2.1-dev CLI

Ubuntu 6.10

php -r "echo filesize('ftp://ftp2.au.netbsd.org/pub/php/php-5.1.1.tar.bz2');"
 [2006-11-13 21:17 UTC] j dot finlay at optusnet dot com dot au
root@phpos:~> php -v                                                     
PHP 5.2.1-dev (cli) (built: Nov  2 2006 20:59:28)
Copyright (c) 1997-2006 The PHP Group
Zend Engine v2.2.0, Copyright (c) 1998-2006 Zend Technologies
root@phpos:~> php -r "echo                                               filesize('ftp://ftp2.au.netbsd.org/pub/php/php-5.1.1.tar.bz2');"

Warning: filesize(): stat failed for ftp://ftp2.au.netbsd.org/pub/php/php-5.1.1.tar.bz2 in Command line code on line 2
root@phpos:~>
 [2006-11-13 21:22 UTC] j dot finlay at optusnet dot com dot au
I've resolved this issue by writing my own (I think, better) fix in PHP, its here: http://au3.php.net/manual/en/function.filesize.php#71098

But this does still not resolve the underlying issue on why its not working for me.
 [2006-12-08 07:49 UTC] bjori@php.net
Don't use --with-curlwrappers
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Fri Jul 04 19:01:37 2025 UTC