Welcome Guest, Not a member yet? Register   Sign In
Accessing "$request" and "validate" from another class
#1

(This post was last modified: 12-15-2019, 01:04 AM by webdevron.)

I have a subfolder inside controller app/Controller/AppManager. Inside it there is a class named "MediaManager.php" which is extended with use CodeIgniter\Controller;.


PHP Code:
<?php

namespace App\Controllers\AppManager;
use 
CodeIgniter\Controller;

class 
MediaManager extends Controller
{
    public function uploadFile(){
        $file $this->request->getFile('file');
        $fileRule = ['file' => 'uploaded[file]|max_size[file,20480]'];

        if( ! $this->validate($fileRule) ) $ret = ['e''FAILED'$this->validator->listErrors()];
        ...
        ...
        ...
    }



Now the problem is, when ever I am going to upload a file, these errors are showing:
  • Call to a member function getFile() on null
  • Argument 1 passed to CodeIgniter\Validation\Validation::withRequest() must implement interface CodeIgniter\HTTP\RequestInterface, null given
How can I access the Request and Validation property in this class?
"Who thinks in code"
Perfectly describes who I am
mbparvez.me
Reply


Messages In This Thread
Accessing "$request" and "validate" from another class - by webdevron - 12-15-2019, 12:56 AM



Theme © iAndrew 2016 - Forum software by © MyBB