Inscrivez-vous ou connectez-vous pour rejoindre votre communauté professionnelle.
If you want to insert a image in my sql database. Its taken a time to retrieve a image from database and if you stored a only path of image then it run fast.
Create table tmp_img
(
id int - act as primary key
name varchar - used to store image name
path varchar - used to retrieve a images on a page
)
And create a one folder in your application and if write a code on copy a image on your application folder.
Can you explain it further? you mean creating an image with php and saving it into mysql, there are numbers of ways to create an image with php GD libraray and imagemagic are the most widely used, i would not recomend to store image in mysql but if you really want it, create an Longnblob type field and put the image data in that.
Working with images is quite easy task in MySQL using php code. Some years back managing images in relational database is quite complex task as at those times relational databases are able to store only textual data so file path to the images are stored in database and images are stored and retrieved externally. Also special file functions are necessary for retrieving images this way and this approach is system dependent (because of path names used). Nowadays, almost all major DBMS support storing of images directly in database by storing images in the form of binary data. Here, I am explaining the method of storing and retrieving images in MySQL database using PHP code.
Inserting images in mysql-:MySQL has a blob data type which can used to store binary data. A blob is a collection of binary data stored as a single entity in a database management system. Blobs are typically images, audio or other multimedia blob objects. MySQL has four BLOB types:
All these types differ only in their sizes.
For my demonstration, lets us create a test table named test_image in MySQL having3 columns show below-: