[eluser]flyenig[/eluser]
ok that didnt work and i tried this and it didnt work either:
Code:
function upload_pic()
{
$this->load->model('photo_model');
$config['upload_path'] = './uploads/';
$config['allowed_types'] = 'gif|jpg|png';
$config['max_size'] = '1000000';
$config['max_width'] = '10244';
$config['max_height'] = '7688';
//$config['file_name'] = $this->photo_model->newPhoto($stupdata['file_ext'])."_".$this->session->userdata('user_id');
$this->load->library('upload', $config);
$arr = $_FILES['userfile']['tmp_name'];
foreach($arr as $key)
{
if (!$this->upload->do_upload($key))
{
echo $error = $this->upload->display_errors();
//$this->load->view('upload_form', $error);
}
else
{
//$photo_data = $this->upload->data('userfile');
//$dataP = array('photo_ext' => $photo_data['file_ext']);
//gather the data
$photodata = array('upload_data' => $this->upload->data());
//the original image file
$imgfile = $photodata['upload_data']['full_path'];
//Insert the photo_id into database
$this->photo_model->newPhoto($photodata['upload_data']['file_ext']);
//create the var to rename the photo
$new_name_img = $config['upload_path'].$this->db->insert_id()."_".$this->session->userdata('user_id').'.jpg';
//finally rename the photo
rename($photodata['upload_data']['full_path'],$new_name_img);
//create the thumbnail
$config['image_library'] = 'GD2';
$config['source_image'] = $new_name_img;
$config['create_thumb'] = TRUE;
$config['thumb_marker'] = '_th';
$config['maintain_ratio'] = TRUE;
$config['width'] = 130;
$config['height'] = 130;
$config['master_dim'] = 'width'; // this sets the resizer to default to height when preserving the ratio
$this->image_lib->clear();
$this->image_lib->initialize($config);
$this->image_lib->resize();
/*if($this->input->post('upldbutton'))
{
$this->photo_model->create_thumbs($this->db->insert_id());
$this->session->set_userdata(array('user_status' => 'uc'));
//$this->db->update('users', array('user_status' => 'uc'));
$userId = $this->session->userdata('user_id');
$data = array(
'profile_img' => $this->db->insert_id()."_".$userId
);
$this->db->where('id',$userId);
$this->db->update('users',$data);
redirect('home');
}
else{
redirect('photo/editPhoto/'.$this->db->insert_id().'/');
}*/
}
}
}