本文介绍了如何在$ _FILES ['']中使用getimagesize()?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在做一个图像上传处理器,我希望它可以检测用户上传的图像的尺寸.

I am doing an image upload handler and I would like it to detect the dimensions of the image that's been uploaded by the user.

所以我开始:

if (isset($_FILES['image'])) etc....

我有

list($width, $height) = getimagesize(...);

我应该如何一起使用它们?

How am i supposed to use them together?

非常感谢

推荐答案

您可以这样做

$filename = $_FILES['image']['tmp_name'];
$size = getimagesize($filename);

// or

list($width, $height) = getimagesize($filename);
// USAGE:  echo $width; echo $height;

结合使用条件,这是一个示例

Using the condition combined, here is an example

if (isset($_FILES['image'])) {
    $filename = $_FILES['image']['tmp_name'];
    list($width, $height) = getimagesize($filename);
    echo $width; 
    echo $height;    
}

这篇关于如何在$ _FILES ['']中使用getimagesize()?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-29 14:30