0

我想获取我的 wordpress 帖子附件的文件大小。但是当我运行该站点时,我得到了这个错误......有人可以帮助我吗?

“警告:filesize(): stat failed for http://XXX.de/webdev/wp-content/uploads/2013/03/example.zip在 C:\Users\XXX\Desktop\XAMPP\htdocs\webdev\wp -content\themes\web dev-theme\modul-page.php 在第 27 行"

<?php
 $a =  filesize($img['url']);
 echo$a;
?>

谢谢!

4

1 回答 1

0

首先检查文件/目录是否可读/可写。

我会在文件中执行此操作,只是为了获得最佳实践。很难确定哪里出了问题,因为您没有指定第 27 行是什么。

if ( file_exists($img['url']) ) {
    $the_file_size = filesize($img['url']);
    if ( $the_file_size >= 0 ) {
        echo $the_file_size . ' bytes';
    } else {
        echo "File size could not be determined";
    }
}
于 2013-03-22T14:56:27.453 回答