What is the most optimal way to recover an image from the database?

-1

When I store the images in the database, a blob is generated that is too large, when I extract it by means of jquery it takes too long, and if there are many images, it is worse since the character string fills several screens, I usually use the images base 64, but as I explain, it is not optimal, is there some way to store without so much weight?

    
asked by Felipe Castillo 23.03.2017 в 15:39
source

2 answers

2

The simplest thing is to save the image in a specific directory, for example "path / to / folder / specific /" and save the name of the file in the table in a varchar type column.

When you want to show it on the site, you only need the name and manually enter the route, for example

echo "<img src='ruta/al/folder/especifico/". $imagen ."'>"

Where in the variable $imagen you stored the name of the file when you consulted the database.

    
answered by 24.03.2017 / 18:01
source
0

As indicated above, a quick solution is to save the route in the database, along with its name. The other is to save the same image in the database, and this can be saved with a type of BLOB file, which gives you a maximum of 4bg approximately to save it in a field. These are in Oracle, MySQL, and SQL Server databases. As a practical solution, I recommend Saul's solution.

    
answered by 03.04.2017 в 14:29