note 20880 deleted from function.filesize by tomsommer
| From: | tomsommer@php.net | Date: | Wed, 01 Sep 2004 17:34:19 +0000 |
| Subject: | note 20880 deleted from function.filesize by tomsommer | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-75888@lists.php.net to get a copy of this message | ||
Note Submitter: x at x dot com
----
If you want to check the size in order to limit the filesize, this should work.
---------------------------------
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";
}
}
--------------------------------
What you do with $file_size_ok is up to you after this.
This should work, but it's a dirty hack.
Good luck!