my attempt filesize of remote file, accessible via http, using php's wrappers has failed.
to 100% sure, let me state, that:
- file exists,
ini_get('allow_url_fopen')returns1,stream_get_wrappers()returnshttpon list andvar_dump(fopen($filename))returnsresource(119) of type (stream).
which means, remote file accessible. , yet, i'm getting:
file_exists($filename): bool(false) is_file($filename): bool(false) is_writable($filename): bool(false) is_readable($filename): bool(false) and attempt of calling filesize($filename) ends filesize(): stat failed for... error.
what missing?
the answer can found in php's docs http/https protocol wrappers. "options" section explains, though protocol allows reading, not support stat() function.
thus, fopen() works charm, while filesize() , other functions, require stat() work, fails wrapper. notice, php documentations says, these functions supports some url wrappers:
as of php 5.0.0, function can used url wrappers. refer supported protocols , wrappers determine wrappers support stat() family of functionality.
seems, http/https wrapper not among them.
you may try use fopen(), works wrapper, implement own version of file size determining function. but, since fopen() opens file (while filesize() reads file size file system / meta data), overkill in scenario, can think of. and... allowed memory size of xxx bytes exhausted (tried allocate yyy bytes) in... closest friend evening.
Comments
Post a Comment