[eluser]Krystian[/eluser]
Hi,
view
Code:
echo form_open_multipart(base_url() . 'media');
echo form_upload(array('name'=>'pro_image[]', 'type'=>'file', 'multiple'=>'multiple', 'accept'=>'image/*'));
echo form_submit('value','OK');
echo form_close();
contoller
Code:
$this->load->model('file_model');
//var_dump($_FILES);
foreach( $_FILES['pro_image']['name'] as $key => $image_name )
{
echo $image_name . '<br />';
$this->file_model->make_upload($image_name, 'jpg|gif|png|jpeg', 1);
}
and model method
Code:
class File_model extends CI_Model {
//upload files
function make_upload($my_file, $types, $resize)
{
$this->load->library('upload');
$config = array(
'allowed_types' => $types, //'jpg|jpeg|gif|png',
'upload_path' => './img/uploads/media_library', //$this->gallery_path,
'overwrite' => true,
'max_size' => 4000
);
$this->upload->initialize($config);
$this->upload->do_upload($my_file);
$image_data = $this->upload->data();
if($resize == 1)
{
$config = array(
'source_image' => $image_data['full_path'],
'new_image' => './img/uploads/media_library/thumbs',
//'maintain_ratio' => true,
'width' => 90,
'height' => 90
);
$this->load->library('image_lib', $config);
$this->image_lib->resize();
}
//return $image_data['file_name'];
}
this code do nothing wrrr.
And the thing is that I cannot see what is wrong with it. Can you give me a tip?
EDIT: when i change to this in file_model
Code:
if(! $this->upload->do_upload($my_file))
{
echo $this->upload->display_errors();
}
CI gave me a message "You did not select a file to upload"