XF 2.1 How to pass file input into _postSave?

grantus

Active member
I have an input field called 'upload':

Code:
<xf:upload name="upload" accept=".mp3" label="Upload" />

I'm accessing it in my controller like this:

Code:
$upload_file = $this->request->getFile('upload', false, false);

In my saveProcess method:

Code:
$form = $this->formAction();
$form->basicEntitySave($store, $input);

I want to be able to move the uploaded file in the _postSave method so I'm trying this:

Code:
protected function _postSave() {

$dataDir = ('data://upload_test/'.$this->store_id.'.mp3');

\XF\Util\File::copyFileToAbstractedPath($upload_file, $dataDir);
    
}

but how can I pass it $upload_file?
 
IMHO there is no clean way to do this in the entity.

I'd probably move this to a service and pass the upload, seems XenForo developers probably would do the same:
Take a look at XF\Pub\Controller\Account to better understand how XenForo implemented profile banners.
 
IMHO there is no clean way to do this in the entity.

I'd probably move this to a service and pass the upload, seems XenForo developers probably would do the same:
Take a look at XF\Pub\Controller\Account to better understand how XenForo implemented profile banners.
I figured that since the file input requires a request->getFile instead of just a standard text input.
 
Top Bottom