php - Verify remote file exists with SplFileInfo -
i'm trying copy remote file server. before doing this, want test of file exists. following code not work, though have manually verified file exists on remote server. have php's allow_url_fopen set on. there missing? old procedural method file_exists() i'm looking replicate.
//... $fileinfo = new \splfileinfo($imagelocation); if($fileinfo->isfile()) { echo "doesn't exist"; } else { echo "exists, copy file here"; }
there no equivalent of file_exists()
splfileinfo
class.
splfileinfo::isfile()
different check, correlates is_file()
function (they share underlying code).
you call file_exists()
function on $imagelocation
, provided references stream wrapper supports stat()
functionality. wrappers such file://
, phar://
, ftp://
(the latter partially) support this.
unfortunately http://
(and https://
) wrapper does not support stat()
calls. means file_exists()
, , other functions call stat()
, return false
.
Comments
Post a Comment