[eluser]Unknown[/eluser]
Hello, I'm triying to make two resizes of four uploaded images. First I make a resize and later I make a thumbnail resize, at the first image all it's ok, but other three only make the thumbnail resize.
¿Could you help me, please?
This is the code of my controller:
Code:
function insertar()
{
$coche_id = $this->usuario_model->insertar_usuario($_POST);
$upload['upload_path'] = "./images/coches/$coche_id";
if (!is_dir($upload['upload_path'])) {
mkdir($upload['upload_path']);
}
$upload['upload_path'] = "./images/coches/$coche_id";
$upload['allowed_types'] = 'jpg';
$upload['max_size'] = '1000';
$this->load->library('upload');
$this->load->library('image_lib');
$i = 0;
foreach($_FILES as $archivo)
{
$i++;
if(!empty($archivo['name']))
{
$upload['new_name'] = $i.'.jpg';
$this->upload->initialize($upload);
if ( ! $this->upload->do_upload('fotos'.$i))
{
$error = array('error' => $this->upload->display_errors());
$this->load->view('usuario_nuevo', $error);
}
else
{
$this->redimensionar_foto($upload['upload_path'].'/'.$i.'.jpg');
}
}
}
redirect("coche/ver/$coche_id");
}
function redimensionar_foto($source_image)
{
$resize['image_library'] = 'gd2';
$resize['source_image'] = $source_image;
$resize['maintain_ratio'] = TRUE;
$resize['width'] = 560;
$resize['height'] = 350;
$resize['master_dim'] = 'width';
$this->image_lib->initialize($resize);
$this->image_lib->resize();
$this->image_lib->clear();
$this->thumbnail_foto($source_image);
}
function thumbnail_foto($source_image)
{
$resize['image_library'] = 'gd2';
$resize['source_image'] = $source_image;
$resize['maintain_ratio'] = TRUE;
$resize['width'] = 140;
$resize['height'] = 105;
$resize['master_dim'] = 'width';
$resize['create_thumb'] = TRUE;
$resize['thumb_marker'] = 'th';
$this->image_lib->initialize($resize);
$this->image_lib->resize();
$this->image_lib->clear();
}