⚠ 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

store image file into database from grocery crud



jep
  • profile picture
  • Member

Posted 07 December 2018 - 22:11 PM

hello guys, im so so newbie.. i have startet from scratch with codeigniter and grocery due a work project.

 

i have a gocery crud flexgrid table in order to register incoming/outcoming building visitors.

.

we store all personal information (name, surname, office, contact, etc etc etc and his photo) into a database and we want to store a picture o these people into database but as you know 

 

$crud->set_field_upload('field','assets/uploads/files'

 

just store reference info not the file (picture)

 

there is any way to do it from grocery crud?

 

Soft versions:

====================================

CodeIgniter v3.1.9

GroceryCrud v1.6.1

database: mysql - > database field is long blob

 

 

thank you in advance for all your help, i hope understand all info you give me.

thank you again

 


jep
  • profile picture
  • Member

Posted 12 December 2018 - 22:36 PM

hi everybody!!! i fell confuse about it...

 

is this questions impossible with this codeigniter/grocery version??

CodeIgniter v3.1.9  /  GroceryCrud v1.6.1

 

 

is my question too simple or stupid that not need to be answered?

i want to store an image file into mysql database field

 

thak you in advance for your response...


Cyn
  • profile picture
  • Member

Posted 26 December 2018 - 12:59 PM

Hi!! sorry for the delay...
 

Did you test with https://www.grocerycrud.com/documentation/options_functions/callback_before_upload ?

 

 


jep
  • profile picture
  • Member

Posted 27 December 2018 - 21:24 PM

 THANK YOU VERY MUCH FOR YOUR TIME. YES Y DO, BUT I WANT TO STORE A FILE IN MY DATABASE AND GROCERYCRUD ONLY STORE FILE NAME AND UPLOAD THE FILE TO A DIRECTORY AT SERVER.

I WILL KEEP LOOKING FOR A WAY TO STORE A FILE..


Cyn
  • profile picture
  • Member

Posted 28 December 2018 - 12:05 PM

Ok, but inside this callback, you can do something like this:

 

 

 

function example_callback_before_upload($files_to_upload,$field_info)
{

  

 

  $photo = base64_encode(fread(fopen($files_to_upload[$field_info->encrypted_field_name]['tmp_name'], "r")));

 

  // Here you can do something to change the name of file into blob in order to save it on db

 

  $files_to_upload[$field_info->encrypted_field_name]['name'] = $photo;  //example!

 

 

}

 

If callback before upload doesn´t work, try with callbak after upload


zaang
  • profile picture
  • Member

Posted 25 January 2019 - 13:20 PM

 THANK YOU VERY MUCH FOR YOUR TIME. YES Y DO, BUT I WANT TO STORE A FILE IN MY DATABASE AND GROCERYCRUD ONLY STORE FILE NAME AND UPLOAD THE FILE TO A DIRECTORY AT SERVER.

I WILL KEEP LOOKING FOR A WAY TO STORE A FILE..

 

You can't upload the file directly into the database


Bint Ahmmed
  • profile picture
  • Member

Posted 24 February 2020 - 08:05 AM

 THANK YOU VERY MUCH FOR YOUR TIME. YES Y DO, BUT I WANT TO STORE A FILE IN MY DATABASE AND GROCERYCRUD ONLY STORE FILE NAME AND UPLOAD THE FILE TO A DIRECTORY AT SERVER.

I WILL KEEP LOOKING FOR A WAY TO STORE A FILE..

Hi, Did u get the solution. I am in exact same situation like u wer... Please help...


Marchoso
  • profile picture
  • Member

Posted 02 March 2020 - 16:11 PM

I think it is better to store the image in a folder than in the database, I usually had problems in the database because it becomes very large and usually gives problems.


jep
  • profile picture
  • Member

Posted 10 March 2020 - 15:31 PM

Hi, Did u get the solution. I am in exact same situation like u wer... Please help...

 

I'VE DECIDED TO STORE FILENAME IN DATABASE AND FILES INTO A CUSTOM FOLDER IN STORAGE

SORRY, I TRIED TO LOOK FOR A SOLUTION BUT I REALLY NEWBIE.