Asked By
pabz07
30 points
N/A
Posted on - 07/21/2011
Hi guys,
I'm Pabz,,,i'm currently developing an application in c#. I have this problem I encountered few days ago. I tried to store an image in mysql and display it on a picture box. I want it to accept .jpg and .bmp format only and limit its size. Or it would be better if I let the user to crop it first before storing it. I want to store the image in the database not just the path of the image. Does any one have idea how to do this? Hope you can help me.
How to store and retrieve images in mySQL using c#?
Hello,
To store a file located on the same host as the server you need to do the following:-
-
You can use this function to store file located on the same host
-
“LOAD_FILE”
-
Note that this function is an admin privilege.
-
INSERT INTO to(image)VALUES(LOAD_FILE('/path/to/”image_name”.jpg') ) ;
-
It is good and is proffered to store images in your database. It is good and proffered to upload to a separate folder or file and
-
store only the location of the image the database.
-
Please try good practices which programming which reduces the chances of errors.
Hope it will help.
Cheers,
Daniel Cruize
How to store and retrieve images in mySQL using c#?
To store images to MySQL database, there is a data type that is responsible for storing images in MySQL. This data type is known as Blobs (Binary Large Objects).
Objects which defend to this data type storing not only images but also other media in a database. There are many ways to save and retrieve images into/from MySQL database. The example below describes how to upload an image (or images) and save it to a MySQL database using an asp.net application using C# code. Try to extract and to apply the only part related to your question in case of the provided solution has more than you want. Kindly, visit the following link
Regards
John