How to store images directly in the MySQL database (1)

Source: Internet
Author: User

Guidance:If you want to put binary data, suchImageFiles and HTML files are directly stored in yourMySQL databaseSo this article is for you! I will show you how to store these files through HTML forms and how to access and use these files. The following sections will solve these problems and teach you how to store images directly in the MySQL database.

Overview:

Create a new database in mysql

Example program for storing files

Example program on how to access a file

Create a new database in mysql

First, you must create a new database in your mysql database. We will store those binary files in this database. In this example, I will use the following structure. To create a database, you must perform the following steps:

The following is a reference clip:
Go to MySql Controller
Enter the command "create database binary_data ;"
Enter the command "use binary_data ;"
Enter the command "create table binary_data (id INT (4) not null AUTO_INCREMENT primary key,
Description CHAR (50), bin_data LONGBLOB, filename CHAR (50), filesize CHAR (50), filetype CHAR (50); "the row cannot be broken)

If there is no accident, the database and table should be created.


Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.