Upload multiple images saving in relational database [Cake 4]

Hi guys, how are you? I’ve had a question for a week and I wanted to see if you guys can help me.
First, sorry for my English, I’m Brazilian and I’m learning English and CakePHP.

I have two tables, one with equipment and one with photos of equipment, and they relate to each other.


I need that when saving the equipment data, the photos are loaded in this relational table,
I would like to know the most correct way to do this, as I need to save several photos from a device at once.

thank you for the help.

I store photos in filesystem and hold paths in DB. Or I’m making folder structure like client_id/photo_id.jpg I don’t know if it is a best method but it works for me, and you don’t have many advantages in storing binary data in DB. Also php file transfer (uploading via form) give you a temp file which you can easy move to known location.

This is also a good excuse to use a plugin. There are quite a few options on the Awesome CakePHP list. Check out the file manipulation and imagery lists.

Personally, I’m a fan of the Upload Plugin. It can store all of the files/images in one table. Then you can reference them in your equipment table, or an equipment_photos table, if you want a many-to-many relationship.