dream07769 2012-10-04 21:48
浏览 45
已采纳

图像文件大小以Php为单位

I am trying to get the file size of an image. If I upload below a 5 MB size image, then this function is properly calculating image size. But if the image file size is exceeded then it is not calculating image file !

$size = filesize($_FILES['file']['tmp_name']);

I am not understanding what the problem is.

  • 写回答

1条回答 默认 最新

  • dongpa9277 2012-10-04 21:58
    关注

    untested code

     if(empty($_FILES) && empty($_POST) && isset($_SERVER['REQUEST_METHOD']) && strtolower($_SERVER['REQUEST_METHOD']) == 'post'){ //catch file overload error...
            $postMax = ini_get('post_max_size'); //grab the size limits...
            echo "<p style=\"color: #F00;\">
    Please note files larger than {$postMax} will result in this error!<br>Please be advised this is not a limitation in the CMS, This is a limitation of the hosting server.
            callMyForm(); //bounce back to the just filled out form.
    }
    elseif(// continue on with processing of the page...
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
编辑
预览

报告相同问题?

手机看
程序员都在用的中文IT技术交流社区

程序员都在用的中文IT技术交流社区

专业的中文 IT 技术社区,与千万技术人共成长

专业的中文 IT 技术社区,与千万技术人共成长

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

客服 返回
顶部