Code:
if(!empty($_FILES))
{
foreach($_FILES as $key => $value)
{
if(!empty($value['name']))
{
$field = $key;
$config['upload_path'] = realpath('public/object');
$config['allowed_types'] = 'jpg|jpeg|gif|avi';
$config['encrypt_name'] = 'TRUE';
$this->load->library('upload', $config);
$this->upload->do_upload($field);
$resarr = $this->upload->data();
$file = $resarr['file_name'];
if($file != '')
{
$oldpath = realpath("public/object")."/".$file;
$fpath = realpath("public/object/thumbs")."/".$file;
if (!copy($oldpath, $fpath))
{
echo "error copy";
}
else
{
$config['image_library'] = 'GD2';
$config['source_image'] = $fpath;
$config['maintain_ratio'] = TRUE;
$config['width'] = 150;
$config['height'] = 110;
$this->load->library('image_lib', $config);
$this->image_lib->resize();
echo $this->image_lib->display_errors();
}
}
echo $this->upload->display_errors();
}
}
}
Code:
if(!empty($_FILES))
{
$this->load->library('upload');
$this->load->library('image_lib');
foreach($_FILES as $key => $value)
{
if(!empty($value['name']))
{
$field = $key;
$config['upload_path'] = realpath('public/object');
$config['allowed_types'] = 'jpg|jpeg|gif|avi';
$config['encrypt_name'] = 'TRUE';
$this->upload->initialize($config);
$this->upload->do_upload($field);
$resarr = $this->upload->data();
$file = $resarr['file_name'];
if($file != '')
{
$oldpath = realpath("public/object")."/".$file;
$fpath = realpath("public/object/thumbs")."/".$file;
if (!copy($oldpath, $fpath))
{
echo "error copy";
}
else
{
$config['image_library'] = 'GD2';
$config['source_image'] = $fpath;
$config['maintain_ratio'] = TRUE;
$config['width'] = 150;
$config['height'] = 110;
$this->image_lib->initialize($config);
$this->image_lib->resize();
echo $this->image_lib->display_errors();
}
}
echo $this->upload->display_errors();
}
}
}