Insert
binary file into MySQL(BLOB) using PHPMyAdmin
Before you start this lesson, I assume that you finished reading
the following tutorials:
- install phpmyAdmin, mysql
, php
- Create Database by using phpMyAdmin
- Working with forms
- Insert Form Data into Database
- Retrieve data from
Database
This tutorial will show you how to insert binary files,
such as PDF file, image files(JPG,GIF, etc), music files(MP3,mid,etc)..by
using phpMyAdmin.
Create MySql Table
In order to shorten the tutorial, we just create a simple
table with 2 columns: one is integer column, the
other one is BLOB column to hold the binary file.
Note, there are 4 BLOB types. Each has different storage
size:
TINYBLOB: 256bytes
- BLOB: 64K bytes
MEDIUMBLOB: 16M bytes
LONGBLOB: 4G bytes
MEDIUMBLOB usually could meet most storage
requirement.
Following this lesson Using
phpMyAdmin Create Database to create the database,one column is no:
int(auto increment) , the other one is image: MEDIUMBLOB. By
select auto increment in "Extra" drop down menu like following for
column no:
no column is auto increment so that we don't need insert
any value about it.
Insert binary file(image, PDF,..) into MySQL
After you create the table, you will see its name on PHPMyAdmin
left panel. Click on it, you will see the following image on the
right panel:
Click on insert, you will see the following image:
The "Browse" button in the above image locate
your binary file( such as PDF, images, .exe files, mp3 file, .mid
files ... etc). Since column no is auto increment,
we don't need insert value for it. Then click on the "GO" button,
which is below the above image.
You just inerted an binary file into MySQL database.
There are other alternative ways to insert binary files
into MySQL:
- Using php
programming insert binary files into MySQL
- Using
HTML Form and php progamming insert binary files into MySQL(local
and remote)
- Using PhpMyAdmin insert binary files.
|