From: Brion Vibber Date: Mon, 2 Nov 2009 17:08:26 +0000 (-0800) Subject: Detect "no file" upload error and, for now at least, ignore it gracefully. X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=73b9e531bf7cab8ba6642f9cb85e4b37b48706d7;p=quix0rs-gnu-social.git Detect "no file" upload error and, for now at least, ignore it gracefully. This was triggering on non-AJAX form submissions for new notices, preventing them from being posted when they contained no attachments. --- diff --git a/lib/imagefile.php b/lib/imagefile.php index 88f4614814..cd2f87e6bd 100644 --- a/lib/imagefile.php +++ b/lib/imagefile.php @@ -79,7 +79,12 @@ class ImageFile @unlink($_FILES[$param]['tmp_name']); throw new Exception(_('Partial upload.')); return; + case UPLOAD_ERR_NO_FILE: + // No file; probably just a non-AJAX submission. + return; default: + common_log(LOG_ERR, __METHOD__ . ": Unknown upload error " . + $_FILES[$param]['error']); throw new Exception(_('System error uploading file.')); return; } diff --git a/lib/mediafile.php b/lib/mediafile.php index d4d184dd0f..29d752f0c6 100644 --- a/lib/mediafile.php +++ b/lib/mediafile.php @@ -152,6 +152,9 @@ class MediaFile throw new ClientException(_('The uploaded file was only' . ' partially uploaded.')); return; + case UPLOAD_ERR_NO_FILE: + // No file; probably just a non-AJAX submission. + return; case UPLOAD_ERR_NO_TMP_DIR: throw new ClientException(_('Missing a temporary folder.')); return; @@ -162,6 +165,8 @@ class MediaFile throw new ClientException(_('File upload stopped by extension.')); return; default: + common_log(LOG_ERR, __METHOD__ . ": Unknown upload error " . + $_FILES[$param]['error']); throw new ClientException(_('System error uploading file.')); return; }