public static function getFileHash($file, $method = 'sha1') {
		if ($method === 'md5') {
			return md5_file($file);
		}
		if ($method === 'sha1') {
			return sha1_file($file);
		}

		throw new InvalidArgumentException(sprintf('Invalid hash method "%s" provided!', $method));
	}
public static function getFileHash($file, $method = 'sha1') {
		if ($method === 'md5') {
			return md5_file($file);
		}
		if ($method === 'sha1') {
			return sha1_file($file);
		}

		throw new InvalidArgumentException(sprintf('Invalid hash method "%s" provided!', $method));
	}
public static function getFileHash ( $ file , $ method = 'sha1' ) { if ( $ method === 'md5' ) { return md5_file ( $ file ) ; } if ( $ method === 'sha1' ) { return sha1_file ( $ file ) ; } throw new InvalidArgumentException ( sprintf ( 'Invalid hash method "%s" provided!' , $ method ) ) ; }
Gets the hash of a file.

You can use this to compare if you got two times the same file uploaded.

@param string $file Path to the file on your local machine.
@param string $method 'md5' or 'sha1'
@throws \InvalidArgumentException
@link http://php.net/manual/en/function.md5-file.php
@link http://php.net/manual/en/function.sha1-file.php
@link http://php.net/manual/en/function.sha1-file.php#104748
@return string
Gets the hash of a file .