Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Upload Class won't see $_FILES
  • I've taken too much time on this. It seems that the Upload Class is not working. I followed the document and came with this:

        public function action_file()
        {
            $path = DOCROOT . 'assets\uploads';
            $setting = array(
                'path'          => trim($path),
                'ext_whitelist' => array('png','jpeg','jpg'),
                'overwrite'     => true
            );
            \Fuel\Core\Upload::process($setting);
            if(\Fuel\Core\Upload::is_valid())
            {
                \Fuel\Core\Upload::save();
                print \Fuel\Core\Upload::get_files();
            }
        }

    My View:

    <form action="../public/debug/file" method="POST" enctype="multipart/form-data">
        <?php print Fuel\Core\Form::file('file_name') ?>
        <input type="hidden" value="placeholder" name="pl"/>
        <input type="submit" value="submit" id="submit"/>
    </form>

    once I submit, I don't see any results. It seems that is_valid == false. I remove it and do upload::save() then upload::get_files(), but it seems it didn't received $_FILES for some reason. I print_r($_FILES) and there is data in it.

    I ask, what am I missing here?
  • Upload works fine.

    If $_FILES contains data, my guess is that validation has failed.

    Debug::dump(Upload::get_files(), Upload::get_errors());

    to see which files valdated (first array), and which ones failed (second array). For the failed ones, it will list the reasons why.
  • The problem was my whitelist entries are wrong in the config. Using the default settings worked.

Howdy, Stranger!

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

In this Discussion