It works in the exactly same way as code igniter. // CodeIgniter example
function do_upload()
{
$config['upload_path'] = './uploads/';
$config['allowed_types'] = 'gif|jpg|png';
$config['max_size'] = '100';
$config['max_width'] = '1024';
$config['max_height'] = '768';
$this->load->library('upload', $config);
if ( ! $this->upload->do_upload())
{
$error = array('error' => $this->upload->display_errors());
$this->load->view('upload_form', $error);
}
else
{
$data = array('upload_data' => $this->upload->data());
$this->load->view('upload_success', $data);
}
}
// same in FuelPHP
function do_upload()
{
// Custom configuration for this upload
$config = array(
'path' => DOCROOT.DS.'uploads/',
'ext_whitelist' => array('img', 'jpg', 'jpeg', 'gif', 'png'),
);
// process the uploaded files in $_FILES
Upload::process($config);
// if there are any valid files
if (Upload::is_valid())
{
// save them according to the config
Upload::save();
// call a model method to update the database
Model_Uploads::add(Upload::get_files());
}
// and process any errors
foreach (Upload::get_errors() as $file)
{
// $file is an array with all file information,
// $file['errors'] contains an array of all error occurred
// each array element is an an array containing 'error' and 'message'
}
}
It's very cool the way you intervened on my question, for sure any time I have a question or a answer I'll be participating on the forum. I have some other codes to share that I'm otimizating to Fuel (and at the same time, learning more).It looks like you're new here. If you want to get involved, click one of these buttons!