<?php
function do_upload()
{
$upload_conf = array(
'upload_path' => realpath('assets/doc/img/real/'),
'allowed_types' => 'gif|jpg|png|JPEG|JPG',
'max_size' => '30000',
'encrypt_name' => TRUE,
'remove_spaces' => TRUE,
'overwrite' => TRUE
);
$this->load->library('upload', $upload_conf);
foreach ($_FILES['userfile'] as $key => $val)
{
$i = 1;
foreach ($val as $v)
{
$field_name = "file_" . $i;
$_FILES[$field_name][$key] = $v;
$i++;
}
}
unset($_FILES['userfile']);
foreach ($_FILES as $field_name => $file)
{
if (!$this->upload->do_upload($field_name))
{
echo $this->image_lib->display_errors();
}
else
{
$upload_data = $this->upload->data();
// Watermark
$ori = $upload_data['file_name'];
$mr = $upload_data['file_path'] . $ori;
$this->watermarking($mr);
/*
//this is the larger image
$config['image_library'] = 'gd2';
$config['source_image'] = $upload_data['full_path'];
$config['new_image'] = 'assets/doc/img/full/' . $upload_data['file_name'];
$config['maintain_ratio'] = TRUE;
$config['width'] = 0;
$config['height'] = 0;
$this->image_lib->initialize($config);
$this->image_lib->resize();
$this->image_lib->clear();
//this is the larger image
$config['image_library'] = 'gd2';
$config['source_image'] = $upload_data['full_path'];
$config['new_image'] = 'assets/doc/img/medium/' . $upload_data['file_name'];
$config['maintain_ratio'] = TRUE;
$config['width'] = 342;
$config['height'] = 342;
$this->image_lib->initialize($config);
$this->image_lib->resize();
$this->image_lib->clear();
//small image
$config['image_library'] = 'gd2';
$config['source_image'] = $upload_data['full_path'];
$config['new_image'] = 'assets/doc/img/small/' . $upload_data['file_name'];
$config['maintain_ratio'] = TRUE;
$config['width'] = 152;
$config['height'] = 152;
$this->image_lib->initialize($config);
$this->image_lib->resize();
$this->image_lib->clear();
//cropped thumbnail
$config['image_library'] = 'gd2';
$config['source_image'] = $upload_data['full_path'];
$config['new_image'] = 'assets/doc/img/thumbnails/' . $upload_data['file_name'];
$config['maintain_ratio'] = TRUE;
$config['width'] = 62;
$config['height'] = 62;
$this->image_lib->initialize($config);
$this->image_lib->resize();
$this->image_lib->clear();
*/
// do it!
if (!$this->image_lib->resize()) {
// if got fail.
//$error['resize'][] = $this->image_lib->display_errors();
echo $this->image_lib->display_errors();
} else {
// otherwise, put each upload data to an array.
$success[] = $upload_data;
}
}
}
// see what we get
if (count($error > 0)) {
$data['error'] = $error;
} else {
$data['success'] = $upload_data;
}
$data['multiupload'] = "multiupload"; // Controller
$data['view'] = "index_multiupload"; // View
$data['module'] = "multiupload"; // Controller
$data['error'] = ' ';
dump($this->upload->data());
echo Modules::run('template/staff', $data);
}
- Output for 4.3.0 - 4.3.11, 4.4.0 - 4.4.9, 5.0.0 - 5.0.5, 5.1.0 - 5.1.6, 5.2.0 - 5.2.17, 5.3.0 - 5.3.29, 5.4.0 - 5.4.45, 5.5.0 - 5.5.38, 5.6.0 - 5.6.40, 7.0.0 - 7.0.33, 7.1.0 - 7.1.33, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.6
preferences:
353.03 ms | 406 KiB | 457 Q