Welcome Guest, Not a member yet? Register   Sign In
Image handling and upload
#1

[eluser]ibnclaudius[/eluser]
I have this form submit, everything works fine, I'm having problem handling the picture, for example, how can I check if the image is a square before uploading it?

Code:
$data['name'] = trim($this->input->post('name'));
$data['username'] = trim($this->input->post('username'));
$data['address'] = trim($this->input->post('address'));

if (!$data['name'] OR !$data['username'] OR !$data['address'])
{
    $data['error'] = 'Preencha todos os campos.';
}
elseif ($data['username'] != $this->session->userdata('username') && $this->nightclubs_model->get_nightclub($data['username']))
{
    $data['error'] = 'Este usuário já existe.';
}
else
{
    $this->load->library('upload');
    $this->upload->initialize(array(
        'upload_path' => './uploads/nightclubs/pictures',
        'allowed_types' => 'gif|jpg|png',
        'file_name' => sha1($this->session->userdata('id')),
        'overwrite' => TRUE
    ));

    if (!$this->upload->do_upload('picture'))
    {
        die($this->upload->display_errors());
    }
    else
    {
        $picture = $this->upload->data();
    }

    $this->settings_model->update_profile($this->session->userdata('id'), $data['name'], $data['username'], $data['address']);

    $this->session->set_userdata('name', $data['name']);
    $this->session->set_userdata('username', $data['username']);
    $this->session->set_userdata('address', $data['address']);

    $data['success'] = 'Seu perfil foi alterado com sucesso!';
}


Messages In This Thread
Image handling and upload - by El Forum - 03-21-2013, 11:28 AM
Image handling and upload - by El Forum - 03-21-2013, 12:41 PM
Image handling and upload - by El Forum - 03-21-2013, 01:43 PM



Theme © iAndrew 2016 - Forum software by © MyBB