[eluser]yabune[/eluser]
Hi,
I'm uploading an image with CI File Uploading class ( a jpg image) and then I'm trying to get the image width with $this->upload->data() but image_width is not recognized...
Here is the code:
Code:
function upload($tag, $w, $h)
{
if ( ! empty($_FILES[$tag]['name'] ) )
{
$CI =& get_instance();
$config['upload_path'] = 'assets/uploads/';
$config['allowed_types'] = 'gif|jpg|png';
$config['max_size'] = '2000';
$config['max_width'] = $this->max_width;
$config['max_height'] = $this->max_height;
$CI->upload->initialize($config);
if ( ! $CI->upload->do_upload($tag))
{
$this->error = $CI->upload->display_errors();
return '';
}
else
{
$uploaded_file = $CI->upload->data();
$config['source_image'] = $uploaded_file['full_path'];
$config['maintain_ratio'] = TRUE;
if($uploaded_file['image_width'] > $w || $uploaded_file['image_heigth'] > $h) {
$config['width'] = $w;
$config['height'] = $h;
}
$CI->image_lib->initialize($config);
if ( ! $CI->image_lib->resize())
{
$this->error = $CI->image_lib->display_errors();
return '';
}
return 'assets/uploads/'.$uploaded_file['file_name'];
}
}
else
{
return '';
}
}
The strange thing is that other image parameters like is_image and image_type are ok.
And if I serialize the $uploaded_file array data, I can see there the image_width and image_height attributes... Don't understand why it fails when I try to access them...
Thank you!