I'm trying to check for the width and height of an image before uploading it and do some checking but after much Google research I came out with this, which also doesn't work.
$tmp = $_FILES["image"]["tmp_name"];
list($width, $height) = getimagesize($tmp);
The error:
Fatal error: Uncaught ValueError: Path cannot be empty in C:\xampp\htdocs\CMS Blog\NewPost.php:12 Stack trace: #0 C:\xampp\htdocs\CMS Blog\NewPost.php(12): getimagesize('') #1 {main} thrown in C:\xampp\htdocs\CMS Blog\NewPost.php on line 12
Here's some of the HTML:
<form action="NewPost.php" method="POST" enctype="multipart/form-data">
<div class="form-group">
<p class="text-warning" style="margin-bottom: 7px;">Select Thumbnail:</p>
<div class="custom-file">
<input class="custom-file-input" type="file" name="image" id="ImageInput" value="" accept="image/png, image/jpeg">
<label for="ImageInput" class="custom-file-label">Upload Image</label>
</div>
</div>
</form>
Does anyone know how to check for the width and height before uploading it? I have been struggling for 2 days now with this problem. Thanks very much!
PS: Using the newest version of XAMPP. And PHP 8.