Welcome Guest, Not a member yet? Register   Sign In
global $mimes return NULL
#1

[eluser]Julio Fagundes[/eluser]
When I restrict mimes types, no files are uploaded (including jpg,gifs etc.) I got the alert 'The filetype you are attempting to upload is not allowed.'.

in my controller.

TROW ERROR
Code:
$config['upload_path'] = './upload';
$config['allowed_types'] = 'gif|jpg|png'; // <<<<<<<<<
$config['encrypt_name']    = true;
$this->load->library('upload', $config);

UPLOAD, OK. but not solve my problem.
Code:
$config['upload_path'] = './upload';
$config['allowed_types'] = '*';  // <<<<<<<<<
$config['encrypt_name']    = true;
$this->load->library('upload', $config);


with native function debug_print_backtrace() in config/mimes.php I got:

#0 include() called at [C:\wamp\www\project\system\core\Output.php:46]
#1 CI_Output->__construct() called at [C:\wamp\www\project\system\core\Common.php:166]
#2 load_class(Output, core) called at [C:\wamp\www\project\system\core\CodeIgniter.php:177]
#3 require_once(C:\wamp\www\project\system\core\CodeIgniter.php) called at [C:\wamp\www\project\index.php:198]

So, we see that has it an include before the require_once


Code:
public function mimes_types($mime)
    {
        global $mimes;

        if (count($this->mimes) == 0)
        {
            if (@require_once(APPPATH.'config/mimes'.EXT))
            {
                var_dump($mimes); // <<<<<<<<<<<< returns NULL
                $this->mimes = $mimes;
                unset($mimes);
            }
        }

        return ( ! isset($this->mimes[$mime])) ? FALSE : $this->mimes[$mime];
    }
/* Location: ./system/libraries/Upload.php */
LINE 950


but with require()

Code:
public function mimes_types($mime)
    {
        global $mimes;

        if (count($this->mimes) == 0)
        {
            if (@require(APPPATH.'config/mimes'.EXT)) // just require
            {
                var_dump($mimes); // <<<<<<<<<<<< returns COMPLETE ARRAY and upload OK.
                $this->mimes = $mimes;
                unset($mimes);
            }
        }

        return ( ! isset($this->mimes[$mime])) ? FALSE : $this->mimes[$mime];
    }


- Where does global $mimes turns into null after the first include ?
#2

[eluser]danmontgomery[/eluser]
This sounds like https://bitbucket.org/ellislab/codeignit...ork-in-201?
#3

[eluser]Julio Fagundes[/eluser]
Thanks man. I had already extended the upload class,
but the bug has been fixed that way too.

cool Smile




Theme © iAndrew 2016 - Forum software by © MyBB