note 22490 added to function.md5-file

From: Date: Thu, 20 Jun 2002 03:21:12 +0000
Subject: note 22490 added to function.md5-file
Groups: php.notes 
Request: Send a blank email to php-notes+get-32028@lists.php.net to get a copy of this message
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 -- http://www.php.net/manual/en/function.md5-file.php http://master.php.net/manage/user-notes.php?action=edit+22490 http://master.php.net/manage/user-notes.php?action=delete+22490 http://master.php.net/manage/user-notes.php?action=reject+22490

« previous php.notes (#32028) next »