Jump to content


store image file into database from grocery crud

upload file database grocery crud

  • Please log in to reply
5 replies to this topic

#1 jep

jep

    Newbie

  • Members
  • Pip
  • 4 posts

Posted 07 December 2018 - 10: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

 



#2 jep

jep

    Newbie

  • Members
  • Pip
  • 4 posts

Posted 12 December 2018 - 10: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...



#3 Cyn

Cyn

    Newbie

  • Members
  • Pip
  • 6 posts

Posted 26 December 2018 - 12:59 PM

Hi!! sorry for the delay...
 

Did you test with https://www.groceryc...k_before_upload ?

 

 



#4 jep

jep

    Newbie

  • Members
  • Pip
  • 4 posts

Posted 27 December 2018 - 09:24 PM

Hi!! sorry for the delay...
 

Did you test with https://www.groceryc...k_before_upload ?

 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..



#5 Cyn

Cyn

    Newbie

  • Members
  • Pip
  • 6 posts

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



#6 zaang

zaang

    Newbie

  • Members
  • Pip
  • 4 posts

Posted 25 January 2019 - 01: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







Also tagged with one or more of these keywords: upload, file, database, grocery crud

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users