• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
post the new name of images in database with insert batch

#1
Hi!
When i post the name of my images in database is the original name and not the new name that i have selected in $config['file_name'].

The images are uploaded on server with the new name (and this is ok), but in database are posted the original name (and isn't ok).

Thanks for help me.
PHP Code:
//
// CONTROLLER
//

public function add()
{
 
 
  if 
(!empty($_FILES))
 
 {
 
   $folder $this->input->post('id_article');
 
   $file_name $folder."_".date('dmy').'_';

 
   if (!is_dir('/media/images/uploads/gallery/'.$folder))
 
   {
 
     mkdir('./media/images/uploads/gallery/' $folder0777TRUE);
 
   }

 
   $files $_FILES;
 
   $count count($_FILES['multimages']['name']);

 
   for($i 0$i $count$i++)
 
   {
 
     // configurazione
 
     $config['upload_path'  './media/images/uploads/gallery/'.$folder;
 
     $config['file_name'    $file_name;
 
     $config['allowed_types'] = 'gif|jpg|png';
 
     $config['max_size'     1024;
 
     $config['max_width'    1920;
 
     $config['max_height'   1080;
 
     $config['overwrite'    FALSE;
 
     $config['remove_spaces'] = TRUE;

 
     $_FILES['multimages']['name'    $files['multimages']['name'][$i];
 
     $_FILES['multimages']['type'    $files['multimages']['type'][$i];
 
     $_FILES['multimages']['tmp_name'] = $files['multimages']['tmp_name'][$i];
 
     $_FILES['multimages']['error'   $files['multimages']['error'][$i];
 
     $_FILES['multimages']['size'    $files['multimages']['size'][$i];

 
     $this->load->library('upload'$config); // carico la libreria di CI
 
     $this->upload->initialize($config); // inizializzo la configurazione

 
     if ($this->upload->do_upload('multimages'))
 
     {
 
       $data = array('upload_data' => $this->upload->data());
 
     }
 
     else
      
{
 
       $this->session->set_flashdata('result''<div class="uk-alert-warning" uk-alert><a class="uk-alert-close" uk-close></a>Si è verificato un problema nel caricamento delle immagini!</div>');
 
       redirect('images/index');
 
     }

 
   }

 
   $name_image  $files['multimages']['name'];
 
   $data = array();

 
   for($i=0$i<$count$i++)
 
   {
 
     $data[$i] = array(
 
       'id_article'  => $this->input->post('id_article'),
 
       'name_image'  => $name_image[$i],
 
       'title_image' => $this->input->post('title_image')[$i],
 
       'text_image'  => $this->input->post('text_image')[$i],
 
       'alt_image'   => $this->input->post('alt_image')[$i],
 
     );

 
   }
 
   $this->Images_model->add_image('tbl_images'$data);

 
   $this->session->set_flashdata('result''<div class="uk-alert-success" uk-alert><a class="uk-alert-close" uk-close></a>Immagini caricate correttamente!</div>');
 
   redirect('images/index');
 
 }

}

//
// MODEL
//

 
 function add_image($table$data)
 
 {
 
   $query $this->db->insert_batch($table$data);
 
 
Reply


Messages In This Thread
post the new name of images in database with insert batch - by eleumas - 02-09-2019, 05:29 AM

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2019 MyBB Group.