<?php function remotefilesize($file) { // SETTINGS $max_file_size = "1000" // in bytes
// Open the file, but only read maximum size $fp = fopen($file, "r"); $first_file_size_read = fread($fp, $max_file_size); fclose($fp);
// Open the file plus one byte... // if there is an extra byte, then it is too big, $fp = fopen("$image", "r"); $second_file_size_read = fread($fp, $max_file_size + 1); fclose($fp);
// Check if they're the same if ($first_file_size_read == $second_file_size_read) { $file_size_ok == "yes"; } }