From a2049e474e116617892de09a0a8fd857f53a4f27 Mon Sep 17 00:00:00 2001 From: Michael M Slusarz Date: Thu, 11 Feb 2010 12:14:36 -0700 Subject: [PATCH] Check that the file exists and has contents when uploading --- framework/Browser/lib/Horde/Browser.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/framework/Browser/lib/Horde/Browser.php b/framework/Browser/lib/Horde/Browser.php index f0b1c633c..21b73d168 100644 --- a/framework/Browser/lib/Horde/Browser.php +++ b/framework/Browser/lib/Horde/Browser.php @@ -1072,7 +1072,10 @@ class Horde_Browser if (!isset($_FILES) || ($error == UPLOAD_ERR_NO_FILE)) { throw new Horde_Browser_Exception(sprintf('There was a problem with the file upload: No %s was uploaded.', $name), UPLOAD_ERR_NO_FILE); } elseif (($error == UPLOAD_ERR_OK) && is_uploaded_file($tmp_name)) { - return; + if (!filesize($tmp_name)) { + throw new Horde_Browser_Exception('The uploaded file appears to be empty. It may not exist on your computer.', UPLOAD_ERR_NO_FILE); + } + // SUCCESS } elseif (($error == UPLOAD_ERR_INI_SIZE) || ($error == UPLOAD_ERR_FORM_SIZE)) { throw new Horde_Browser_Exception(sprintf('There was a problem with the file upload: The %s was larger than the maximum allowed size (%d bytes).', $name, min($uploadSize, Horde_Util::getFormData('MAX_FILE_SIZE'))), $error); -- 2.11.0