PHP

【PHP & MySQL】How to Save Image File

 


 

Introduction

In these videos, I’m going to show you how to save, display, and delete image files using PHP and MySQL database.

When saving image files, you can choose to upload them into a folder or save them into a database. We go with the latter, saving image files into MySQL database.

I also show you how to create a simple lightbox with Bootstrap. You don’t need to write any JavaScript or jQuery code for this lightbox.
 

Hope you enjoy 🙂
 
 

Environment

MAMP / PHP version 7.2.10 (Required PHP 5.4 or later)
Text Editor Coda2
Browser Google Chrome

 
 

Video

【PHP & MySQL】How to Save Image File – #1 Introduction

 

 
 

MySQL Database

Database name: my_image
Table name: images
 


 

Name type
image_id int / AUTO_INCREMENT
image_name varchar(256)
image_type varchar(64)
image_content mediumblob
image_size int
created_at datetime

 
 

Sample Code

HTML (Bootstrap & Font Awesome)

 

Insert, Display, and Delete an image file into MySQL database

functions.php

 

list.php

 

image.php

 

delete.php

 

ABOUT ME
Sara
Working as a freelance programmer in Japan. I try to make coding as simple as possible. Hope you enjoy coding 🙂