Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
im getting this error ..No uploaded files are selected.
  • I'm getting this error "Fuel\Core\Fuel_Exception [ Error ]: No uploaded files are selected." when im trying to set-up an upload image.. is there something i miss? I already set the path of my upload but its always appearing on same error. -CONTROLLER- function action_submit()
    {
    if(Input::method()== 'POST')
    {
    Upload::get_files();
    Upload::save();
    }
    } -MY VIEW- echo Form::open('welcome/submit',array('enctype'=>'multipart/form-data'));
    echo Html::br(1).Form::input(array('name'=>'img_url','type'=>'file')).Html::br(1);
    echo Html::br(1).Form::submit('Submit');?>
  • Read the documentation. Upload::save() doesn't return anything, so you can't use it in an if statement. The correct way of using it is documented at the top of the page, under 'Usage Example'.
  • Thanks for everyone!
    Thanks to Andrew! Andrew Wayne told me, what wrong in my code.
    Here my examples: Code in controller:
    http://pastebin.com/T9Ak0DSb Code in form (HTML):
    http://pastebin.com/nDJ6GVtX
  • Nitarm Nope wrote on Monday 18th of July 2011:
    I'm getting this error "Fuel\Core\Fuel_Exception [ Error ]: No uploaded files are selected." when im trying to set-up an upload image.. is there something i miss? I already set the path of my upload but its always appearing on same error. -CONTROLLER- function action_submit()
    {
    if(Input::method()== 'POST')
    {
    Upload::get_files();
    Upload::save();
    }
    } -MY VIEW- echo Form::open('welcome/submit',array('enctype'=>'multipart/form-data'));
    echo Html::br(1).Form::input(array('name'=>'img_url','type'=>'file')).Html::br(1);
    echo Html::br(1).Form::submit('Submit');?>

    hello,
    you firstly should do UPload::save()
    and only then, get_files() from Fuel docs: http://d.pr/vo8P
  • No, you need to Upload::process() them before you can save() them...
  • Thanks huglester and WanWizard for the advice..
    I found my error in my form by looking view page source on my browser
    i wrote this : Form::open('welcome/submit',array('enctype'=>'multipart/form-data')); which produce in html like this.. <form action="http://localhost/welcome/submit"; accept-charset="utf-8" method="post">
    <input name="enctype" value="multipart/form-data" type="hidden" id="form_enctype" /> which will definitely error "no uploaded files are selected"
  • Nitarm Nope wrote on Monday 18th of July 2011:
    Thanks huglester and WanWizard for the advice..
    I found my error in my form by looking view page source on my browser
    i wrote this : Form::open('welcome/submit',array('enctype'=>'multipart/form-data')); which produce in html like this.. <form action="http://localhost/welcome/submit"; accept-charset="utf-8" method="post">
    <input name="enctype" value="multipart/form-data" type="hidden" id="form_enctype" /> which will definitely error "no uploaded files are selected"
    Could you explain for others how do you solved a problem?
    For example I do not understand DOCS. No examples, not full info.
    Recently I very disappointed in fuelphp docs.
  • The error here is that the Form::open() method is used wrong. It accepts either a URI as first parameter, or an array with tag attributes. So you need to pass an array if you have more then only the URI:
    Form::open( array('action' => 'welcome/submit', 'enctype' => 'multipart/form-data') );
    
  • Harro Verton wrote on Sunday 4th of September 2011:
    The error here is that the Form::open() method is used wrong. It accepts either a URI as first parameter, or an array with tag attributes. So you need to pass an array if you have more then only the URI:
    Form::open( array('action' => 'welcome/submit', 'enctype' => 'multipart/form-data') );
    
    I am not found a problem in code. :(
    I used your code in my project.
    Could you show your config upload file? and code in controller?
  • I don't understand. The TS wrote that he used this code:
    echo Form::open('welcome/submit',array('enctype'=>'multipart/form-data'));
    

    and that generates the incorrect HTML, as shown above. You asked how that issue was fixed, to which I replied that it needs to be coded like this:
    echo Form::open( array('action' => 'welcome/submit', 'enctype' => 'multipart/form-data') );
    
  • Harro Verton wrote on Tuesday 6th of September 2011:
    I don't understand. The TS wrote that he used this code:
    echo Form::open('welcome/submit',array('enctype'=>'multipart/form-data'));
    

    and that generates the incorrect HTML, as shown above. You asked how that issue was fixed, to which I replied that it needs to be coded like this:
    echo Form::open( array('action' => 'welcome/submit', 'enctype' => 'multipart/form-data') );
    
    Part of my code:
    /in controller:
    function action_submit()
        &#123;
        if(isset($_POST))
        &#123;
            $config = array(
        'path' => DOCROOT.DS.'files',
        'randomize' => true,
        'ext_whitelist' => array('img', 'jpg', 'jpeg', 'gif', 'png'),
    );
        \Fuel\Core\Upload::process($config);
            if(\Fuel\Core\Upload::save())
            &#123;
                echo 'Everything ok, img saved';
            }
            else
            &#123;
                echo 'Something wrong in code';
            }
    
        }
        else
        &#123;
            echo 'NO $_post';
            
        }
    
        }
    

    in index with form:
    <?php
    echo Form::open(array('action' => 'upload/submit', 'method'=>'Post', 'enctype'=>'multipart/form-data'));
    echo Html::br(1).Form::input(array('name'=>'img_url','type'=>'file')).Html::br(1);
    echo Html::br(1).Form::submit('Submit');?>
    

    I got echo 'Something wrong in code '. Whats wrong?

Howdy, Stranger!

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

In this Discussion