still insert data to database with errors when upload images

edited September 2012 in Modules
I have a image, it's size is bigger than $config['assets_upload_max_height'].
If I create a item, then upload the big image, it will show the [size limit error notification].
The ploblem is: the data insert to the database even the error happends.

How can I check this error before save data to database, tried

function on_before_save()
{
var_dump($this->get_errors());
exit;
}

no errors there.

excuse me for my poor English.

help!!!!!!!!!!

Comments

  • edited 7:25PM
    The error wouldn't appear in the get_errors method. You may want to try and replicate the "is_allowed_dimensions" method on the Upload class.
  • edited 7:25PM
    "is_allowed_dimensions" method works fine
    and in fuel/controllers/module.app line 1453:
    [code]
    if (!$this->upload->do_upload($file))
    {
    $errors = TRUE;
    add_error($this->upload->display_errors('', ''));
    $this->session->set_flashdata('error', $this->upload->display_errors('', ''));
    }
    [/code]

    these codes handle the error "upload_invalid_dimensions"

    the flash notification shows and that means I get a error, the "Create" operation should cancel right here,

    but data still insert to the database
  • edited 7:25PM
    ok, there is a ploblem in FUELcms

    in fuel/controllers/module.app line 505:

    else if ($id = $this->model->save($posted))

    line 513:

    if (!$this->_process_uploads($posted))

    FUEL do create first then do the upload, so nomatter the image valid or not, data already insert into the database
  • edited 7:25PM
    I customize the "create" method

    change and move these codes:

    // process $_FILES
    if (!$this->_process_uploads($posted))
    {
    $this->session->set_flashdata('error', get_error());
    redirect(fuel_uri($this->module_uri.'/create/'));
    return false;
    }

    under:

    $this->_run_hook('before_save', $posted);


    now it works what i want

    not sure that would cause other problems
  • edited 7:25PM
    Thank you 66beta your post helped me as well. :)
  • edited 7:25PM
    U R welcome Sigal, cute dogs :)
    my name is Kyle

    careful with change the framework's source code
Sign In or Register to comment.