Today we will teach you how to upload images to the MYSQL database using PHP. In this tutorial, we need to create three php files: readdir. php
Today we will teach you how to upload images to the MYSQL database using PHP. In this tutorial, we need to create three php files:
Readdir. php-code for storing images in the database
Image. php-code for displaying the actual image
View. php-show how you call the image code in the database
1. create a database
Create table 'images '(
'Imgid' int not null AUTO_INCREMENT,
'Sixfourdata' longtext not null,
Primary key ('imgid ')
);
READDIR. PHP
Specific content:
$ Dbcnx = mysql_connect ("localhost", "username", "password ");
Mysql_select_db ("base64imgdb ");
?>
'Open a directory
"./"
The 'readdir. php file is located in this directory:
$ Path = "./";
$ Dir_handle = opendir ($ path) or die ("Unable to open directory $ path ");
The following is a difficult part. you need to take a good look at this: classify images and read some of the data in use.
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.