Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
File::download throws error ErrorException [ Warning ]: finfo::finfo() [finfo.finfo]: Failed to load
  • FuelPHP throws error ErrorException [ Warning ]: finfo::finfo() [finfo.finfo]: Failed to load magic database at '' when calling File::download(). Funny thing is I already use File::download in another controller action and there it works... but not here. My code is simple:

                $config = array(
                    'path' => APPPATH.'downloads'.DS.'licenses',
                    'ext_whitelist' => array('lic'),
                );
               
                Upload::process($config);

                if (Upload::is_valid())
                {
                    Upload::save();

                    foreach(Upload::get_files() as $file):
                        $original_filename = $file['name'];
                        $extension = $file['extension'];
                        $file_contents = @file_get_contents(APPPATH.'downloads'.DS.'licenses'.DS.$original_filename);
                       
                        $registered_filename = $file['filename'].'.registered.'.$extension;
                        $base_path = APPPATH.'downloads'.DS.'licenses';

                        File::update($base_path, $registered_filename, $status["XML"]);

                        return File::download($base_path.DS.$registered_filename, $original_filename);
                        exit(0);
                    endforeach;
                }
  • It uses

    \Config::get('file.magic_file', null)

    has that been overwritten, removed, set to some other value somewhere (by mistake)?
  • Nope... i use default core/config/file.php configuration, and I don't set this option on the fly...
  • Could have been a Config::set('file', $something) as well.

    If it's not set (by default it's null), then it uses whatever PHP thinks is default. And that is either always there, or never...
  • Looks like a problem in my dev environment... no problem in production!
  • You can try working around it by finding the location of your local magic file, make sure it can be read by your webserver user, and create a file.php config file in config/development, in which you add

    return array('magic_file' => [your local file path here]);

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion