⚠ 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 forum is read-only and soon will be archived. ⚠


store image file into database from grocery crud

upload file database grocery crud

  • Please log in to reply
8 replies to this topic

#1 jep

jep

    Newbie

  • Members
  • Pip
  • 6 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
  • 6 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
  • 8 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
  • 6 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
  • 8 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
  • 6 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



#7 Bint Ahmmed

Bint Ahmmed

    Newbie

  • Members
  • Pip
  • 1 posts

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



#8 Marchoso

Marchoso

    Newbie

  • Members
  • Pip
  • 7 posts

Posted 02 March 2020 - 04: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.



#9 jep

jep

    Newbie

  • Members
  • Pip
  • 6 posts

Posted 10 March 2020 - 03: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.







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