diff --git a/modules/cms/widgets/AssetList.php b/modules/cms/widgets/AssetList.php index 3dda5d1b3..a37643560 100644 --- a/modules/cms/widgets/AssetList.php +++ b/modules/cms/widgets/AssetList.php @@ -57,8 +57,6 @@ class AssetList extends WidgetBase parent::__construct($controller, []); $this->bindToController(); - - $this->checkUploadPostback(); } /** @@ -622,10 +620,12 @@ class AssetList extends WidgetBase } /** - * Checks the current request to see if it is a postback containing a file upload - * for this particular widget. + * Process file uploads submitted via AJAX + * + * @return void + * @throws ApplicationException If the file "file_data" wasn't detected in the request or if the file failed to pass validation / security checks */ - protected function checkUploadPostback() + public function onUpload() { $fileName = null; diff --git a/modules/cms/widgets/assetlist/assets/js/assetlist.js b/modules/cms/widgets/assetlist/assets/js/assetlist.js index f430c669c..4fb3d41cc 100644 --- a/modules/cms/widgets/assetlist/assets/js/assetlist.js +++ b/modules/cms/widgets/assetlist/assets/js/assetlist.js @@ -83,6 +83,9 @@ } AssetList.prototype.onUploadFail = function(file, message) { + if (file.xhr.status === 413) { + message = 'Server rejected the file because it was too large, try increasing post_max_size'; + } if (!message) { message = 'Error uploading file' } @@ -170,6 +173,7 @@ $.each(self.$form.serializeArray(), function (index, field) { formData.append(field.name, field.value) }) + xhr.setRequestHeader('X-OCTOBER-REQUEST-HANDLER', self.alias + '::onUpload') self.onUploadStart() }) }