More info : http://www.php-mysql-tutorial.com/php-mysql-upload.php
Using PHP to upload files into MySQL database sometimes needed by some web application. For instance for storing pdf documents or images to make som kind of online briefcase (like Yahoo briefcase).
For the first step, let's make the table for the upload files. The table will consist of.
- id : Unique id for each file
- name : File name
- type : File content type
- size : File size
- content : The file itself
For column content we'll use BLOB data type. BLOB is a binary large object that can hold a variable amount of data. MySQL have four BLOB data types, they are :
- TINYBLOB
- BLOB
- MEDIUMBLOB
- LONGBLOB
Since BLOB is limited to store up to 64 kilobytes of data we will use MEDIUMBLOB so we can store larger files ( up to 16 megabytes ).
id INT NOT NULL AUTO_INCREMENT,
name VARCHAR(30) NOT NULL,
type VARCHAR(30) NOT NULL,
size INT NOT NULL,
content MEDIUMBLOB NOT NULL,
PRIMARY KEY(id)
);
More info : http://www.php-mysql-tutorial.com/php-mysql-upload.php
No comments:
Post a Comment