How to store and retrieve images in mySQL using c#?

Asked By 30 points N/A Posted on -
qa-featured

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.

SHARE
Best Answer by Daniel Cruize
Best Answer
Best Answer
Answered By 0 points N/A #86502

How to store and retrieve images in mySQL using c#?

qa-featured

Hello,

To store a file located on the same host as the server you need to do the following:-

  1. You can use this function to store file located on the same host
  2.  “LOAD_FILE”
  3. Note that this function is an admin privilege.
  4. INSERT INTO to(image)VALUES(LOAD_FILE('/path/to/”image_name”.jpg') ) ;
  5. 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
  6. store only the location of the image the database.
  7. Please try good practices which programming which reduces the chances of errors.

Hope it will help.

Cheers,

Daniel Cruize

Answered By 0 points N/A #86503

How to store and retrieve images in mySQL using c#?

qa-featured

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

Login/Register to Answer

Related Questions