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 version7.2.10 (Required PHP 5.4 or later)
Text EditorCoda2
BrowserGoogle Chrome

 
 

Video

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

 

 
 

MySQL Database

Database name: my_image
Table name: images
 


 

Nametype
image_idint / AUTO_INCREMENT
image_namevarchar(256)
image_typevarchar(64)
image_contentmediumblob
image_sizeint
created_atdatetime

 
 

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 🙂