hi, i get the follwing error message:
<b>Notice</b>: Access to undefined property fileService in <b>/usr/src/fileserver/app/controllers/FilesController.php</b> on line <b>74</b><br />
<br />
<b>Fatal error</b>: Uncaught Error: Call to a member function uploadFiles() on null in /usr/src/fileserver/app/controllers/FilesController.php:74
Stack trace:
#0 [internal function]: App\Controllers\FilesController->addAction()
#1 [internal function]: Phalcon\Mvc\Micro\LazyLoader->__call('addAction', Array)
#2 [internal function]: Phalcon\Mvc\Micro\LazyLoader->callMethod('addAction', Array, NULL)
#3 /usr/src/fileserver/public/index.php(59): Phalcon\Mvc\Micro->handle()
#4 {main}
thrown in <b>/usr/src/fileserver/app/controllers/FilesController.php</b> on line <b>74</b><br />
this is my addAction function in FileController:
public funtion addActioin()
{
try {
if ($this->request->hasFiles()){
foreach ($this->request->getUploadedFiles() as $file){
echo $file->getName();
echo $file->getRealType();
if ($this->extensionCheck($file->getRealType())){
$uploads = $file;
// echo FILES_PATH.$uploads->getName();
// $uploads->moveTo(FILES_PATH.$uploads->getName());
}
else {
$errors['file'] = 'This typ of file is not supported';
}
}
$this->fileService->uploadFiles($uploads);
}
} catch (ServiceException $e) {
switch ($e->getCode()) {
case AbstractService::ERROR_ALREADY_EXISTS:
case FilesService::ERROR_UNABLE_CREATE_FILE:
throw new Http422Exception($e->getMessage(), $e->getCode(), $e);
default:
throw new Http500Exception(_('Internal Server Error'), $e->getCode(), $e);
}
}
}
and this is the uploadFiles function in FileService:
public function uploadFiles(array $uploads) {
try {
foreach ($uploads as $upload) {
// $random = new Random();
$upload->moveTo(FILES_PATH.$upload->getName());
}
} catch (\PDOException $e) {
if ($e->getCode() == 23505) {
throw new ServiceException('File already exists', self::ERROR_ALREADY_EXISTS);
} else {
throw new ServiceException($e->getMessage(). $e->getCode(), $e); }
}
}
Can someone please tell me why i get this error? Thanks in advance