How to upload images on to phpmyadmin

Im trying to upload images into the database for my admin.php

Don’t understand you.

Upload onto?

What is admin.php?

You need to give a better description of what you want!

the fucntion of admin.php is this is where the admin can upload pictures. Then insert the pictures to the database

AFAIK images in MySQL databases need to be of the type “blob” is that the case here?

Make sure that FILE access is turned on - then in phpmyadmin you can use a FILE command in the insert that loads the image into the database.- for example

INSERT INTO myimagetable (image_name, myimage) VALUES ('myimage.jpg', LOAD_FILE('images/myimage.jpg'));

If you can’t turn FILE access on then you will need to write a PHP script to read the image into a variable and then insert that into the field in the database. Alternatively you’d need a script that loads the image and displays the value of the variable and then copy/paste that into the INSERT.

Hi @Mimi123 and welcome to the forum.

I find that it is better to load image paths to the database because it is easier to change image dimensions and quality. Also reduces the size of your database which is good for downloads or backups.

2 Likes

Hi,
When you say,

Does that mean that the actual image file is saved to a directory and the path is in the database? Is this how it is normally done?
Thanks,
shane

It is an option and there have been many heated arguments on numerous forums. Try searching to find the discussions.

1 Like

That’s because there are clear benefits both ways depending on the circumstances and a lot of those arguing one side have never experienced the situation where the other way is better.

Generally, the bigger the application the more likely it will benefit from storing images in the database - particularly when the database accesses involve transaction processing. Smaller applications generally benefit more by NOT storing the images in the database.

1 Like

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.