简体   繁体   中英

PHP: getimagesize returns false for uploaded file

I know there are many similar questions but none of them addresses this particular problem. Anyway, I'm trying to get the uploaded image dimensions before getting it saved on the server. Bellow is the code that I tried so far

print_r($_FILES);
$temp = getimagesize($_FILES['aaiu_upload_file']['tmp_name']);
print_r($temp);
var_dump($temp);

it outputs:

Array
(
    [aaiu_upload_file] => Array
        (
            [name] => Screenshot_4.png
            [type] => image/png
            [tmp_name] => /home/username/tmp/phpN4uRRA
            [error] => 0
            [size] => 19765
        )

)

bool(false)

So, is there something I'm doing wrong? your help is highly appreciated.

My PHP Version is 7.3.1

As in php getimagesize Manual

use this to get image dimension :

list($width, $height, $type, $attr) = getimagesize($_FILES['aaiu_upload_file']['tmp_name']);
echo $width.'x'.$height;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM