Problem in uploading an image & storing the image in the database

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

Hi everybody,

I need some help. I want to develop a web application that uses MySQL database in the backend. I developed the database. I have created the table name person_info that stores detailed information about different person’s information. Now I want to use it to store uploaded image in a column for a record.

So I searched for a different slob and encryption related information on forums but I didn’t get that. I also need some help related to uploading a file to server. Because of that, I am using a form to submit all my information but can catch the image in the server. So I need some help for uploading image and how to store that image in the server? Thanks in advance.

SHARE
Best Answer by Brice
Best Answer
Best Answer
Answered By 0 points N/A #106886

Problem in uploading an image & storing the image in the database

qa-featured

Hi,

I'm Brice. You can't exactly put your images into your database, what you can do is put the directory of your image into your database and retrieve it during the process of your website. What you can do is create a folder, name it whatever you want, and put all the images you will be using in there, ideally you should put this on the root folder of your web application. Now in your database, make a column specifically for the image of the entity you are referring to, put the name of the image there and just retrieve it in your program every time you need it. You should create a variable that holds the folder name of the images for convenience in your application.

Answered By 0 points N/A #106888

Problem in uploading an image & storing the image in the database

qa-featured

If you want to upload images into MySQL database, first you have to create the database with a field to store images. In your case you have already created the database. So use the ‘alter table' command to add a column to your database. The data type of the column must be a blob type. Depending on the size of the images you want to upload, you can add one of the blob types available in MySQL.

MySQL defines four blob types as tinyblob, blob, mediumblob and largeblob according to the maximum length of value that they can hold. Now you can use the MySQL command ‘insert into’ to upload images.

Related Questions