As one post to make the download a few facial pictures?

Hello, tell me how to solve this problem
I have not the decision itself and as all this happens.
As at the moment I do.
Create 2 tablica in the database. The first posts where filled with the text data of the post. And second images in which to store the image name and id to which the post belongs to this picture.

And here is a point that I don't understand. Here's an example page, add post there are 2 forms 1-load images 2-add a post.Ie you can first upload images by adding the id of the future post which will be created later. And here the time and if the person downloads the pictures and then gets distracted and does not add to this post and after a while will create another post that these pictures will become attached to it.Ie they will remain in the database.

Maybe I did not correctly originally doing? Tell me is very necessary.
If it is not clear described the problem let me know.
March 19th 20 at 09:10
1 answer
March 19th 20 at 09:12
Add post to database, get last insert id
Ship pictures in a folder with the name of this ID
Recording images with names is not needed.the second table is unnecessary
Wouldn't creating a separate module for a file - good idea, it is convenient.
There can be stored and the original file name and its size, that would not apply to FS, that would be it. And a lot of things poleznogo, and give the file by means of the web server.

Not to mention the possibility of building relationships. - Jennings.Bailey commented on March 19th 20 at 09:15
@Jennings.Bailey, it all can be done on any storage, just a dB for this as for me too much
How would the conversion to dB is also an appeal to the FS - Fanny.Parker commented on March 19th 20 at 09:18
@Fanny.Parker, reference to databases, caches, and it can be faster than direct access to the file, especially if it's big and in the folder a lot.

This all can be done on any storage

Especially the connections =) - Jennings.Bailey commented on March 19th 20 at 09:21
@Jennings.Bailey, it all depends on implementation, for example, if you need meta-symbols can be put in the same folder as the json file with descriptions. So you can and even put the blob files - Fanny.Parker commented on March 19th 20 at 09:24
Thanks for the tip. - marilou_Reiche commented on March 19th 20 at 09:27

Find more questions by tags Web Development