Support new onUpload() AJAX handler for uploads instead of postback takeovers.

Fixes #5104. Refs: 4f7e2995c7
This commit is contained in:
Luke Towers 2020-06-05 16:01:22 -06:00
parent d64c3850ff
commit c03fd66aeb
2 changed files with 9 additions and 5 deletions

View File

@ -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;

View File

@ -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()
})
}