Jump to content


I need heeeeelp

image save url upload grocery grocerycrud

  • Please log in to reply
2 replies to this topic

#1 Renzo Darugna

Renzo Darugna

    Newbie

  • Members
  • Pip
  • 2 posts

Posted 08 October 2015 - 03: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

 



#2 Amit Shah

Amit Shah

    grocery CRUD Master

  • Advanced Member
  • PipPipPip
  • 1,192 posts
  • LocationMumbai, India

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.



#3 aida

aida

    Newbie

  • Members
  • Pip
  • 3 posts

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"







0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users