获取图像高度和宽度PHP [英] Get image height and width PHP

查看:100
本文介绍了获取图像高度和宽度PHP的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,我需要动态获取上传图像的高度和宽度。

Hello I need to get the height and width on the fly of an uploaded image.

这是我正在使用的PHP函数,但它不会返回任何内容宽度和高度..

This is the PHP function I am using, but it does not return anything for the width and height..

你能帮我吗?

list($width, $height, $type, $attr) = getimagesize($_FILES["Artwork"]);
$min_width = "1000";
$min_height = "1000";
if ((($_FILES["Artwork"]["type"] == "image/gif") || ($_FILES["Artwork"]["type"] == "image/jpeg") || ($_FILES["Artwork"]["type"] == "image/jpg")
|| ($_FILES["Artwork"]["type"] == "image/pjpeg")) && ($_FILES["Artwork"]["size"] < 20000000) && ($width > $min_width) && ($height > $min_height) && ($width == $height))
  {


  if ($_FILES["Artwork"]["error"] > 0)
    {
    //echo "Return Code: " . $_FILES["Artwork"]["error"] . "<br />";


   }else{
      move_uploaded_file($_FILES["Artwork"]["tmp_name"],
      $path_image . $imageName);
      header("Location: http://pitchmystuff.co.uk/m/digidist/tracks/".$idAlbum."");
      }



   }else{
    //echo "invalid file";

    echo '<script>
    alert("There was an error uploading your coverart file. Please check the requirements and try again.'.$width.$height.'");
    document.location ="http://pitchmystuff.co.uk/m/digidist/albums/";
    </script>';


    }


推荐答案

应该是

list($width, $height, $type, $attr) = getimagesize($_FILES["Artwork"]['tmp_name']);

参见 http://www.php.net/manual/en/features.file-upload.post-method.php

这篇关于获取图像高度和宽度PHP的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆