Upload and store an image in the Database with PHP

Опубликовано: 13 Сентябрь 2024
на канале: Makitweb
13k
81

This video shows how you can store an image and retrieve it from MySQL database using PHP.

I show 2 ways -
1. Storing the image file in the server and save file name in the MySQL table. Retrieve image by file name.
2. Saving the image base64 encoded value in the MySQL table. Display image using base64.

NOTE -
Replace following code in index.php file -
$image_base64 = base64_encode(file_get_contents($_FILES['file']['tmp_name']) );

with - 
$image_base64 = base64_encode(file_get_contents('upload/'.$name) );

Read tutorial and download code -

Upload and Store video to MySQL Database with PHP -
How to upload Image file using AJAX and jQuery -
How to upload file with JavaScript and PHP -
How to upload Multiple files with JavaScript and PHP -

Subscribe for more tutorials:


Stay Connected With Us:
Website:
Facebook:
Twitter: