⚠ In case you've missed it, we have migrated to our new website, with a brand new forum. For more details about the migration you can read our blog post for website migration. This is an archived forum. ⚠

  •     

profile picture

I need heeeeelp



Renzo Darugna

Renzo Darugna
  • profile picture
  • Member

Posted 08 October 2015 - 15:32 PM

I have a problem,.

When i upload a image with grocerycrud, only save the name of image in the database. What i can do to save the url concatenated with the name of image in the database? My site is sistema.zupa.delivery

 


Amit Shah

Amit Shah
  • profile picture
  • Member

Posted 12 October 2015 - 08:29 AM

Well Grocery crud is designed to manage the uploaded images to store only the name and there is a good reason to the same. The same is used for to be able to retrieve, change / alter / delete, etc by the library. If u append the url (which u surely can) .. u gonna defeat the functionality of GC library itself. Then it will be you who will have to manage the edit / view of the image manually. If thats fine ... go ahead - add the code.. if not.. i will recommend leave it as it is .. and append the path where u displaying the image in the code.


aida

aida
  • profile picture
  • Member

Posted 02 November 2015 - 06:43 AM

in controller you have to add the image path.you can call a rename image function.means you have to set the path. but while doing this the image path get doubled in grocery crud,for that problem you have to edit the grocerycrud.php.

 

$crud->set_field_upload('s_photo','uploads');
            $crud->callback_after_update(array($this,'rename_serviceimg_db'));
            $crud->callback_after_insert(array($this,'rename_serviceimg_db'));
 
  function rename_serviceimg_db($post_array,$primary_key)
  {
  
  
 
  if(strlen($post_array['s_photo']>0))
  {
   if(strpos($post_array['s_photo'],'/')==false)//if the photo contains a '/'
  {
    $path_photo=$this->config->item('base_url')."/uploads/".$post_array['s_photo'];
    //echo "haaaaaoooooo".$path_photo; die();
   }
   else
  {
   $ph_name=strrchr($post_array['s_photo'],"/");//extarcting the name of image from path
    $path_photo= $this->config->item('base_url')."/uploads/".substr($ph_name,1,strlen($ph_name)); 
  }
  $dt = array("s_id" => $primary_key,"s_photo" => $path_photo);
         $this->db->update('tbl_services',$dt,array('s_id' => $primary_key));
  }
        return true;
   }

 

 

 

 

and edit the grocerycrud.php ,change $file_url=       to "value"