Check that the file exists and has contents when uploading
authorMichael M Slusarz <slusarz@curecanti.org>
Thu, 11 Feb 2010 19:14:36 +0000 (12:14 -0700)
committerMichael M Slusarz <slusarz@curecanti.org>
Thu, 11 Feb 2010 19:58:30 +0000 (12:58 -0700)
framework/Browser/lib/Horde/Browser.php

index f0b1c63..21b73d1 100644 (file)
@@ -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);