php - 获取图片高宽PHP

标签 php image image-size

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

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

你能帮帮我吗?

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 - 获取图片高宽PHP,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7570831/

相关文章:

javascript - 通过 Ajax 向 PHP 后端提交表单返回错误

php - 添加项目后 Sylius 不记得购物车

android - 来自 URL 的 setimageBitmap 不适合我想要的大小

ios - 如何找出给定 UIImage 大小的最大可能文件大小是多少?

php - 使用 SQL windows 函数编写查询来计算一个国家/地区城市人口的运行总数

php - MySQL - 计算日期范围内的行出现次数,但将 null 转换为 0 以便显示

java - 将多张图片合二为一

iphone - 图像缩放、 ScrollView 、裁剪

html - CSS 图像未正确对齐,留下空白

php - 图像调整大小 % 不同的比率