What are the potential pitfalls of trying to retrieve image dimensions using getimagesize with URL file-access disabled in server configuration?

When trying to retrieve image dimensions using getimagesize with URL file-access disabled in server configuration, the function may not be able to access the image file via URL. To solve this issue, you can download the image file locally using PHP's file handling functions and then use getimagesize on the local file path.

$url = 'https://example.com/image.jpg';
$localPath = 'image.jpg';

// Download the image file
file_put_contents($localPath, file_get_contents($url));

// Get image dimensions
$dimensions = getimagesize($localPath);

// Output image dimensions
echo 'Image width: ' . $dimensions[0] . 'px<br>';
echo 'Image height: ' . $dimensions[1] . 'px';