Welcome Guest, Not a member yet? Register   Sign In
upload one image and two pdf files from one form
#1

[eluser]Krystian[/eluser]
Hello,

the goal is to have 3 inputs
img
pdf1
pdf2

and uplod everything into one folder ( for image create thumb )

I`ve created a model
1st parameter is the name of input
2nd parameter collects allowed extensions
3rd parameter determines if we want to resize
Code:
function do_upload($my_file, $types, $flaque) {
  
  $this->load->library('upload');
  $config = array(
   'allowed_types' => $types,  //'jpg|jpeg|gif|png',
   'upload_path' => $this->gallery_path,
   'overwrite' => true,
   'max_size' => 2000
  );
  
  $this->upload->initialize($config);

  $this->upload->do_upload($my_file);
  $image_data = $this->upload->data();
  
  if($flaque == 1)
  {
   $config = array(
    'source_image' => $image_data['full_path'],
    'new_image' => $this->gallery_path . '/thumbs',
    //'create_thumb' => TRUE,
    'maintain_ration' => true,
    'width' => 150,
    'height' => 100
   );
  
   $this->load->library('image_lib', $config);
   $this->image_lib->resize();
  }
  
  
}

so after submiting form into controller

Code:
function index() {
  
  $this->load->model('Gallery_model');
  
  if ($this->input->post('upload')) {
  
   $this->Gallery_model->do_upload('myFile', 'jpg|gif|png|jpeg', 1);
  
   $this->Gallery_model->do_upload('pdf1', 'pdf', 0);
  
  }
  
  $data['images'] = $this->Gallery_model->get_images();
  
  $this->load->view('gallery', $data);
  
}
everything is working fine - upload success but now how can I save file names into the database?





Theme © iAndrew 2016 - Forum software by © MyBB