Skip to content

MVC Usage

Joey Smith edited this page Jun 13, 2023 · 1 revision

Requirements

  1. A class (model usually) that will expose handleUpload and handleDelete methods.

These methods are solely responsible for "what" should happen to the file when it is uploaded or deleted. If you want the information saved to a db, then this is when it should happen.

  1. Your Controller must implement the UploaderAwareInterface and should use the UploaderAwareTrait to implement the interface.

  2. Your file should come in via a file upload under the POST key file-data

$eventResponse = $this->getEventManager()->trigger(UploaderEvent::EVENT_UPLOAD, $yourModel, $postData['file-data']);
if ($eventResponse->last()) {
   // upload success
}
Clone this wiki locally