V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
V2EX 提问指南
zhaoyafei
V2EX  ›  问与答

怎样仿照这三句PHP程序,写出一句“判断图片的尺寸宽度小于500px”的PHP程序来?

  •  
  •   zhaoyafei · 2011-01-20 11:42:50 +08:00 · 4508 次点击
    这是一个创建于 4865 天前的主题,其中的信息可能已经有所发展或是发生改变。
    <?php
    if ($_SERVER['REQUEST_METHOD'] == 'POST')
    {
    if (!is_uploaded_file($_FILES["upfile"]["tmp_name"]))
    //是否存在文件
    {
    echo "<font color='red'>文件不存在!</font>";
    exit;
    }

    $file = $_FILES["upfile"];
    if($max_file_size < $file["size"])
    //检查文件大小
    {
    echo "<font color='red'>文件太大!</font>";
    exit;
    }

    if(!in_array($file["type"], $uptypes))
    //检查文件类型
    {
    echo "<font color='red'>只能上传图像文件或Flash!</font>";
    exit;
    }
    2 条回复    1970-01-01 08:00:00 +08:00
    Sai
        1
    Sai  
       2011-01-20 11:44:45 +08:00
    getimagesize()
    bobhero
        2
    bobhero  
       2011-01-21 10:16:34 +08:00
    不知道这个算不算一句
    call_user_func( function($size){ list($width,$height) = $size; return $width>500 and $height>500; }, getimagesize('a.png')));
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   1802 人在线   最高记录 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 31ms · UTC 16:39 · PVG 00:39 · LAX 09:39 · JFK 12:39
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.