zhaoyafei
V2EX  ›  问与答

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

  •  
  •   zhaoyafei · Jan 20, 2011 · 5083 views
    This topic created in 5597 days ago, the information mentioned may be changed or developed.
    <?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 replies    1970-01-01 08:00:00 +08:00
    Sai
        1
    Sai  
       Jan 20, 2011
    getimagesize()
    bobhero
        2
    bobhero  
       Jan 21, 2011
    不知道这个算不算一句
    call_user_func( function($size){ list($width,$height) = $size; return $width>500 and $height>500; }, getimagesize('a.png')));
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   2998 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 45ms · UTC 12:53 · PVG 20:53 · LAX 05:53 · JFK 08:53
    ♥ Do have faith in what you're doing.