"Attempting to get a non-object property" when loading a file that is not saved
I have a file-linked model that uses OctoberCMS system_files.
public $attachOne = [
'return_file' => ['System\Models\File', 'public' => false, 'delete' => true]
];
In the .yaml fields I have a form
return_file:
label: Attach File
type: fileupload
mode: file
span: right
Now, before or after saving this, I want to move an image from its directory to a custom one in my plugin. afterSave () doesn't seem to return the file path to move it.
However, in the system_files, I can see that in the MySQL workbench it actually dumped it.
However, when I click save in the backend I get "Attempting to get a non-object property"
Here's what's in the afterSave () function.
public function afterSave()
{
$custom_path = plugins_path() . '/acme/request/uploads/';
$file = $this->return_file->getPath();
$move_file = $file->move($custom_path);
}
Is it even possible to upload to the backend and move the file before / after saving?
+3
source to share