What are the potential drawbacks of using file_exist() and filesize() functions over HTTP in PHP?

When using file_exist() and filesize() functions over HTTP in PHP, potential drawbacks include slower performance due to network latency and security risks if the remote file is not properly validated. To mitigate these issues, consider downloading the file locally before using these functions to improve performance and ensure the file's integrity.

$remoteFile = 'http://example.com/file.txt';
$localFile = 'file.txt';

// Download the remote file locally
file_put_contents($localFile, file_get_contents($remoteFile));

// Check if the local file exists and get its size
if (file_exists($localFile)) {
    $fileSize = filesize($localFile);
    echo "File size: " . $fileSize . " bytes";
} else {
    echo "Local file does not exist.";
}