note 22490 deleted from function.md5-file by nlopess
| From: | nlopess@php.net | Date: | Sun, 12 Sep 2004 17:52:52 +0000 |
| Subject: | note 22490 deleted from function.md5-file by nlopess | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-76549@lists.php.net to get a copy of this message | ||
Note Submitter: derek at sybodek dot com
----
The md5_of_file function will not work with offsite files. If you wish to use offsite files, you
cannot use the filesize($file) function because it needs direct access to the file. To get past
this, just set your own, or if it is user input just have them supply it in the form. I use
something around 350k just to be safe. Here is the modified md5_of_file for those that don't
have the md5_file function and need to md5 files remotely. Locally the above listed function still
works:
//////////////////////////////////////////
function md5_remote_file($input,$estFilesize){
$fd = @fopen($input, "r");
if ($fd){
$fileContents = fread($fd, $estFilesize);
return md5($fileContents);
@fclose($fd);
} else {
return false;
}
}
////////////////////////////////////
If anyone knows a better way to get the size of a remote file, please email me.
Derek Hinch