⚠ 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

Saving Image path In the database



Tindi_

Tindi_
  • profile picture
  • Member

Posted 03 April 2013 - 18:22 PM

Hi guys,

 

I have been using grocery crud for just over a week and I love it! I just have a few questions.

 

1. How do I save an uploaded images path in the database? For example I upload the image "cat.png"  to "assets/uploads/images" how do i save the path "assets/uploads/images/cat.png" to the database? at the moment it saves cat.png only.

 

 

Any help would be appreciated. Thanks!

 


Zalo

Zalo
  • profile picture
  • Member

Posted 04 April 2013 - 17:19 PM

I am not sure about this cause I haven't tried it myself but I think you might be able to set at least part of the directory in the database.

 

1) you set the path to "./" (which is the document_root) - Keep in mind that with this, any file uploaded will be on the document_root directory until you move/delete it

2) you do a callback_before_insert/update that moves the file from your document_root to the folder you actually want.

3) In that same callback, you prepend that directory to the $post['your_file_field'] variable.

 

That may work. As I've said, I haven't tried it myself, but if it does the trick for you...

The other option (I can think of) is to actually modify the GC library file.

 

Quick question: Why are you trying to save the upload path to the database?


Renzo Darugna

Renzo Darugna
  • profile picture
  • Member

Posted 08 October 2015 - 16:00 PM

Tindi_

Can you solved the problem? I have the same problem


Amit Shah

Amit Shah
  • profile picture
  • Member

Posted 12 October 2015 - 08:26 AM

Well.. mind it.. the solution provided will definately help  you store the path in the table... but it also will fail the GC to identify the actual image when in edit / view. Cuz it automatically appends the path to the image. It will rather be recommended to append the path in the code where u using it rather then storing the same in the table.

 

Happy GCing :)