From 07cdad29a4c180398f44db2011b174f560c679d2 Mon Sep 17 00:00:00 2001 From: Benjamin Renard Date: Mon, 4 May 2020 18:01:13 +0200 Subject: [PATCH] LSformRule :: filesize : improve by avoiding to create a temporary file --- public_html/includes/class/class.LSformRule_filesize.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/public_html/includes/class/class.LSformRule_filesize.php b/public_html/includes/class/class.LSformRule_filesize.php index 89752155..cdcce2cb 100644 --- a/public_html/includes/class/class.LSformRule_filesize.php +++ b/public_html/includes/class/class.LSformRule_filesize.php @@ -39,9 +39,10 @@ class LSformRule_filesize extends LSformRule { * @return boolean true si la valeur est valide, false sinon */ public static function validate ($value,$options,$formElement) { - $file = LSsession :: getTmpFile($value); - - $size = filesize($file); + // According to PHP doc, strlen() returns the number of bytes rather + // than the number of characters in a string. + // See: https://www.php.net/manual/en/function.strlen.php + $size = strlen($value); $maxSize = LSconfig :: get('params.maxSize', null, 'int', $options); if (is_int($maxSize) && $size > $maxSize)