June 7, 2011

How to save pictures in MySQL

Question by JKAUSHALYA

I want to save pictures(mostly JPEG) to MySQL database. I saw most people say save pictures elsewhere and add link to table. It is the most efficient way. But i need to encrypt my pictures and want to set user privileges. So how can i do this. Please can anyone help me.

I’m using a C client program to connect to the MySQL.

Answer by genobis

Not a good idea, but if you really have to do it this way, use BLOBs (a data type).

http://dev.mysql.com/doc/refman/5.0/en/blob.html

Answer by Starx

Yes, do not insert pictures to the database table. It reduces manageability heavility. Also, when the database increases, the performance is reduced significantly. Let DBMS manage data and let File Management System manage files.
Better, save the pictures on a table and then later only retrieve the images from a folder, once a valid user is found.

Author: Nabin Nepal (Starx)

Hello, I am Nabin Nepal and you can call me Starx. This is my blog where write about my life and my involvements. I am a Software Developer, A Cyclist and a Realist. I hope you will find my blog interesting. Follow me on Google+

...

Please fill the form - I will response as fast as I can!