Hướng dẫn how to insert image in mysql database using phpmyadmin - cách chèn hình ảnh vào cơ sở dữ liệu mysql bằng phpmyadmin

Tải lên hình ảnh/video vào cơ sở dữ liệu và hiển thị nó bằng PHP là cách tải hình ảnh lên cơ sở dữ liệu và tìm nạp nó từ cơ sở dữ liệu. Sử dụng mã PHP, người dùng tải lên hình ảnh hoặc video mà họ đang nhập vào cơ sở dữ liệu một cách an toàn và hình ảnh nên được lưu vào một vị trí cụ thể bằng cách tìm nạp các hình ảnh này từ cơ sở dữ liệu. Nếu bất kỳ trang web nào chứa chức năng để tải lên hình ảnh/ Video với một số chi tiết, sau đó bằng cách sử dụng mã này, chúng tôi sẽ tải hình ảnh vào cơ sở dữ liệu của bạn và liệu bạn có muốn xác định những gì người đó phải được tải lên hay không. Và bằng mã này, hình ảnh được tải lên nơi lưu trong hệ thống của bạn nơi bạn được cung cấp vị trí.
If any of the websites contain the functionality to upload images/videos with some detail, then by using this code we will upload the image into your database and whether you would like to ascertain what the person has got to be uploaded. And by this code the image which is uploaded that where save in your system where you are given the location.

Cách tiếp cận: Đảm bảo bạn đã cài đặt XAMPP hoặc WAMP Server trên máy của bạn. Trong hướng dẫn này, chúng tôi sẽ sử dụng máy chủ WAMP. Make sure you have XAMPP or WAMP server installed on your machine. In this tutorial, we will be using the WAMP server.

1. Tạo cơ sở dữ liệu: Đầu tiên, chúng tôi sẽ tạo một cơ sở dữ liệu có tên ‘GeekSforGeeks. Bạn có thể sử dụng cơ sở dữ liệu hiện tại của mình hoặc tạo một cơ sở mới.First, we will create a database named ‘geeksforgeeks‘. You can use your existing database or create a new one.

Tạo cơ sở dữ liệu Geekforgeeks

2. Tạo bảng: Tạo một bảng có tên ‘Hình ảnh‘. Bảng chứa hai trường: & nbsp;: Create a table named ‘image‘. The table contains two fields: 

  • ID - int (11)
  • Tên tệp - Varchar (100)

ID nên được tăng tự động (AI). Cấu trúc bảng của bạn sẽ trông như thế này:Auto incremented(AI). Your table structure should look like this:

cấu trúc bảng của hình ảnh ”

Hoặc bạn có thể tạo một bảng bằng cách sao chép và dán mã sau vào bảng SQL của phpmyadmin của bạn.you can create a table by copying and pasting the following code into the SQL panel of your PHPMyAdmin.

CREATE TABLE IF NOT EXISTS `image` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `filename` varchar(100) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;

Để làm điều này từ bảng điều khiển SQL, hãy tham khảo ảnh chụp màn hình sau.

Hướng dẫn how to insert image in mysql database using phpmyadmin - cách chèn hình ảnh vào cơ sở dữ liệu mysql bằng phpmyadmin

Tạo một bảng ‘hình ảnh” từ bảng điều khiển SQL

Chúng tôi sẽ sử dụng Bootstrap ở đây để sử dụng điều khiển biểu mẫu Bootstrap. Dưới đây là mã bao gồm liên kết CDN bootstrap trong phần đầu của mã HTML.

Tạo thư mục và tệp:

Bây giờ chúng tôi sẽ tạo một thư mục có tên là hình ảnh. Các tệp được khách hàng tải lên trên máy chủ sẽ được lưu trữ trong thư mục này. Tạo index.php và style.css. Giữ thư mục dự án chính của bạn (ví dụ tại đây .. tương ứng. Cấu trúc thư mục sẽ trông như thế này:image“. The files uploaded by the client on the server will be stored in this folder. Create index.php and style.css. Keep your main project folder (for example here.. GeeksForGeeks) in the “C://wamp64/www/“, if you are using WAMP or “C://xampp/htdocs/” folder if you are using the XAMPP server respectively. The folder structure should look like this:

Cấu trúc thư mục

Chương trình: Bây giờ, chúng tôi sẽ tạo biểu mẫu HTML để tải lên các tệp hình ảnh (bạn có thể tải lên bất kỳ loại tệp nào như .pdf hoặc .mp4) và sẽ hiển thị hình ảnh đã tải lên. Now, we will create an HTML form for uploading image files (you can upload any type of file like .pdf or .mp4) and will display the uploaded image.

  • Mã HTML: & NBSP;

HTML

<html>

<head>

Các

upload_max_size = 100M
post_max_filesize = 100M
0<
upload_max_size = 100M
post_max_filesize = 100M
8
upload_max_size = 100M
post_max_filesize = 100M
9______

C:\wamp64\bin\apache\apache2.4.27\bin
9head>

<3>

Các

<2<<4 <5

C:\wamp64\bin\apache\apache2.4.27\bin
0<7

html5___

>2<>4 html8

C:\wamp64\bin\apache\apache2.4.27\bin
0>7

html5

C:\wamp64\bin\apache\apache2.4.27\bin
97>

html5___

>2<>4 html8

C:\wamp64\bin\apache\apache2.4.27\bin
0>7

html5

C:\wamp64\bin\apache\apache2.4.27\bin
97>

<2

C:\wamp64\bin\apache\apache2.4.27\bin
9<4>

upload_max_size = 100M
post_max_filesize = 100M
0
C:\wamp64\bin\apache\apache2.4.27\bin
97>

>2<>1 html8

C:\wamp64\bin\apache\apache2.4.27\bin
0>4

Các

____10

upload_max_size = 100M
post_max_filesize = 100M
24
upload_max_size = 100M
post_max_filesize = 100M
25

<2

upload_max_size = 100M
post_max_filesize = 100M
27
upload_max_size = 100M
post_max_filesize = 100M
28
upload_max_size = 100M
post_max_filesize = 100M
29
upload_max_size = 100M
post_max_filesize = 100M
30
upload_max_size = 100M
post_max_filesize = 100M
31

<2

upload_max_size = 100M
post_max_filesize = 100M
27
upload_max_size = 100M
post_max_filesize = 100M
34
upload_max_size = 100M
post_max_filesize = 100M
29
upload_max_size = 100M
post_max_filesize = 100M
36
upload_max_size = 100M
post_max_filesize = 100M
37

upload_max_size = 100M
post_max_filesize = 100M
0
upload_max_size = 100M
post_max_filesize = 100M
45

<2

upload_max_size = 100M
post_max_filesize = 100M
39
upload_max_size = 100M
post_max_filesize = 100M
40
upload_max_size = 100M
post_max_filesize = 100M
29
upload_max_size = 100M
post_max_filesize = 100M
42
upload_max_size = 100M
post_max_filesize = 100M
43

upload_max_size = 100M
post_max_filesize = 100M
0
upload_max_size = 100M
post_max_filesize = 100M
24
upload_max_size = 100M
post_max_filesize = 100M
25

<2

upload_max_size = 100M
post_max_filesize = 100M
54

upload_max_size = 100M
post_max_filesize = 100M
0
upload_max_size = 100M
post_max_filesize = 100M
45

upload_max_size = 100M
post_max_filesize = 100M
0
C:\wamp64\bin\apache\apache2.4.27\bin
97>

C:\wamp64\bin\apache\apache2.4.27\bin
93>

C:\wamp64\bin\apache\apache2.4.27\bin
9html>

<2<

upload_max_size = 100M
post_max_filesize = 100M
48
upload_max_size = 100M
post_max_filesize = 100M
49

  • Giải thích mã PHP: & NBSP;
  • Trước tiên chúng tôi chọn các bản ghi từ bảng trong biến $ Truy vấn.
  • Sau đó, kết quả $ sẽ thực thi truy vấn.
  • Mặc dù vòng lặp được sử dụng để tìm nạp tất cả các bản ghi trong dữ liệu $ để tìm nạp hình ảnh từ cơ sở dữ liệu.
  • Và cuối cùng, các hình ảnh được định sẵn được hiển thị với sự trợ giúp của thẻ. Trong thẻ, chúng tôi đang chuyển vị trí của tệp được tải lên trên máy chủ và tên của tệp hình ảnh trong cơ sở dữ liệu của chúng tôi. The style.css is the file that styles the form into a new design and the code is given below. 
     

Mã CSS: The Style.css là tệp tạo kiểu biểu mẫu thành một thiết kế mới và mã được đưa ra dưới đây. & Nbsp; & nbsp;

upload_max_size = 100M
post_max_filesize = 100M
67

upload_max_size = 100M
post_max_filesize = 100M
0
upload_max_size = 100M
post_max_filesize = 100M
69
upload_max_size = 100M
post_max_filesize = 100M
70
upload_max_size = 100M
post_max_filesize = 100M
71
upload_max_size = 100M
post_max_filesize = 100M
31

upload_max_size = 100M
post_max_filesize = 100M
73
upload_max_size = 100M
post_max_filesize = 100M
74
upload_max_size = 100M
post_max_filesize = 100M
70
upload_max_size = 100M
post_max_filesize = 100M
71
upload_max_size = 100M
post_max_filesize = 100M
31

upload_max_size = 100M
post_max_filesize = 100M
73
upload_max_size = 100M
post_max_filesize = 100M
79

upload_max_size = 100M
post_max_filesize = 100M
54

upload_max_size = 100M
post_max_filesize = 100M
81

upload_max_size = 100M
post_max_filesize = 100M
0
upload_max_size = 100M
post_max_filesize = 100M
83
upload_max_size = 100M
post_max_filesize = 100M
70
upload_max_size = 100M
post_max_filesize = 100M
85
upload_max_size = 100M
post_max_filesize = 100M
31

upload_max_size = 100M
post_max_filesize = 100M
0
upload_max_size = 100M
post_max_filesize = 100M
88
upload_max_size = 100M
post_max_filesize = 100M
89
upload_max_size = 100M
post_max_filesize = 100M
70
upload_max_size = 100M
post_max_filesize = 100M
91
upload_max_size = 100M
post_max_filesize = 100M
31

upload_max_size = 100M
post_max_filesize = 100M
0
upload_max_size = 100M
post_max_filesize = 100M
94
upload_max_size = 100M
post_max_filesize = 100M
91
upload_max_size = 100M
post_max_filesize = 100M
31

____10

upload_max_size = 100M
post_max_filesize = 100M
69
upload_max_size = 100M
post_max_filesize = 100M
70
C:\wamp64\bin\apache\apache2.4.27\bin
00
C:\wamp64\bin\apache\apache2.4.27\bin
01
upload_max_size = 100M
post_max_filesize = 100M
31

Các

upload_max_size = 100M
post_max_filesize = 100M
54

C:\wamp64\bin\apache\apache2.4.27\bin
11

upload_max_size = 100M
post_max_filesize = 100M
0
upload_max_size = 100M
post_max_filesize = 100M
83
upload_max_size = 100M
post_max_filesize = 100M
70
upload_max_size = 100M
post_max_filesize = 100M
85
upload_max_size = 100M
post_max_filesize = 100M
31

____10

upload_max_size = 100M
post_max_filesize = 100M
69
upload_max_size = 100M
post_max_filesize = 100M
70
C:\wamp64\bin\apache\apache2.4.27\bin
00
C:\wamp64\bin\apache\apache2.4.27\bin
01
upload_max_size = 100M
post_max_filesize = 100M
31

upload_max_size = 100M
post_max_filesize = 100M
54

C:\wamp64\bin\apache\apache2.4.27\bin
24

upload_max_size = 100M
post_max_filesize = 100M
0
upload_max_size = 100M
post_max_filesize = 100M
83
upload_max_size = 100M
post_max_filesize = 100M
70
C:\wamp64\bin\apache\apache2.4.27\bin
28
upload_max_size = 100M
post_max_filesize = 100M
31

upload_max_size = 100M
post_max_filesize = 100M
0
upload_max_size = 100M
post_max_filesize = 100M
88
upload_max_size = 100M
post_max_filesize = 100M
89
upload_max_size = 100M
post_max_filesize = 100M
70
upload_max_size = 100M
post_max_filesize = 100M
91
upload_max_size = 100M
post_max_filesize = 100M
31

upload_max_size = 100M
post_max_filesize = 100M
0
upload_max_size = 100M
post_max_filesize = 100M
74
upload_max_size = 100M
post_max_filesize = 100M
70
C:\wamp64\bin\apache\apache2.4.27\bin
39
upload_max_size = 100M
post_max_filesize = 100M
31

upload_max_size = 100M
post_max_filesize = 100M
0
upload_max_size = 100M
post_max_filesize = 100M
69
upload_max_size = 100M
post_max_filesize = 100M
70
C:\wamp64\bin\apache\apache2.4.27\bin
44
upload_max_size = 100M
post_max_filesize = 100M
31

upload_max_size = 100M
post_max_filesize = 100M
54

C:\wamp64\bin\apache\apache2.4.27\bin
47

____10

upload_max_size = 100M
post_max_filesize = 100M
69
upload_max_size = 100M
post_max_filesize = 100M
70
C:\wamp64\bin\apache\apache2.4.27\bin
39
upload_max_size = 100M
post_max_filesize = 100M
31

upload_max_size = 100M
post_max_filesize = 100M
0
upload_max_size = 100M
post_max_filesize = 100M
83
upload_max_size = 100M
post_max_filesize = 100M
70
C:\wamp64\bin\apache\apache2.4.27\bin
56
upload_max_size = 100M
post_max_filesize = 100M
31

upload_max_size = 100M
post_max_filesize = 100M
0
C:\wamp64\bin\apache\apache2.4.27\bin
59
upload_max_size = 100M
post_max_filesize = 100M
70
C:\wamp64\bin\apache\apache2.4.27\bin
61
upload_max_size = 100M
post_max_filesize = 100M
31

upload_max_size = 100M
post_max_filesize = 100M
54

Bạn có thể sao chép mã trên và đề cập trực tiếp vào mã chính hoặc tạo một liên kết giống nhau trong mã HTML và đính kèm với mã chính được đưa ra dưới đây. Như đã đề cập rằng nếu bạn liên kết tệp bảng kiểu, bạn nên tạo một tệp khác ở định dạng .CSS và lưu nó ở nơi lưu tệp chính sẽ được lưu. Biểu mẫu được tạo với sự trợ giúp của phương thức POS hình ảnh từ bất kỳ thư mục nào của hệ thống trong một thư mục cụ thể mà bạn đang đề cập và lưu trữ nó vào cơ sở dữ liệu dưới dạng thư mục. & NBSP;stylesheet file you should create another file in .css format and save it in the place where the main file is to be saved. The form created with the help of the POST method and the enctype=”multipart/form-data”is the action which encodes the files and allows you to send them through POST.
Now we are working on the PHP code for the transfer of the image from any folder of the system in a particular folder which you are mentioning and storing it into the database as a directory.
 

  • Mã PHP: Mã PHP dành cho hình ảnh tải lên, tên tệp được lưu bằng index.php, bạn cũng có thể lưu nó bằng một tên khác như bạn thích. & Nbsp; & nbsp; The PHP code is for the uploading images, the file name is saved with the index.php, you can also save it with another name as you prefer. 
     

PHP

C:\wamp64\bin\apache\apache2.4.27\bin
64

C:\wamp64\bin\apache\apache2.4.27\bin
65
C:\wamp64\bin\apache\apache2.4.27\bin
66

C:\wamp64\bin\apache\apache2.4.27\bin
67
upload_max_size = 100M
post_max_filesize = 100M
29html0
upload_max_size = 100M
post_max_filesize = 100M
31

C:\wamp64\bin\apache\apache2.4.27\bin
71
C:\wamp64\bin\apache\apache2.4.27\bin
72___

Các

Các

____10

C:\wamp64\bin\apache\apache2.4.27\bin
96
upload_max_size = 100M
post_max_filesize = 100M
29
C:\wamp64\bin\apache\apache2.4.27\bin
98
C:\wamp64\bin\apache\apache2.4.27\bin
99
C:\wamp64\bin\apache\apache2.4.27\bin
78
upload_max_size = 100M
post_max_filesize = 100M
31

upload_max_size = 100M
post_max_filesize = 100M
003 0405060706html0061112

____1014

upload_max_size = 100M
post_max_filesize = 100M
2916
upload_max_size = 100M
post_max_filesize = 100M
31

upload_max_size = 100M
post_max_filesize = 100M
01903061412

____10

C:\wamp64\bin\apache\apache2.4.27\bin
71 26
C:\wamp64\bin\apache\apache2.4.27\bin
8706
C:\wamp64\bin\apache\apache2.4.27\bin
9630

<232 33

upload_max_size = 100M
post_max_filesize = 100M
31

____103637 38

<232 41

upload_max_size = 100M
post_max_filesize = 100M
31

upload_max_size = 100M
post_max_filesize = 100M
0
upload_max_size = 100M
post_max_filesize = 100M
54

upload_max_size = 100M
post_max_filesize = 100M
54

upload_max_size = 100M
post_max_filesize = 100M
45

Giải thích: Sau đây là giải thích để tạo mã PHP như sau: & nbsp; The following are the explanation to create the PHP code which is the following: 

  • Error_Reporting (0) là để nhận lỗi 0 trong khi mã PHP đang chạy.
  • $ _files làm việc phía sau hiện trường. Nó đang được sử dụng để tải lên các tệp thông qua phương thức bài HTTP và giữ các thuộc tính của các tệp.
  • $ fileName là một tên được sử dụng để xác định duy nhất một tệp máy tính được lưu trữ trong hệ thống tệp.
  • $ tempname được sử dụng để sao chép tên gốc của tệp được tải lên cơ sở dữ liệu dưới dạng tên TEMP nơi hình ảnh được lưu trữ sau khi tải lên.
  • $ Thư mục xác định đường dẫn của hình ảnh được tải lên vào cơ sở dữ liệu đến thư mục nơi bạn muốn được lưu trữ. Các. Và tên tệp $ được sử dụng để tìm nạp hoặc tải lên tệp.“./image/” is the folder name where the image is to be saved after the upload. And the $filename is used for fetching or uploading the file.
  • $ dB, dòng cơ bản cho bất kỳ mã PHP nào để kết nối với cơ sở dữ liệu.
  • $ SQL được sử dụng để chèn hình ảnh vào cơ sở dữ liệu của hình ảnh tên bảng vào tên tệp biến.image to the variable filename.
  • MySQLI_Query là chức năng thực hiện truy vấn $ DB và $ SQL.
  • Bây giờ, hãy để di chuyển hình ảnh được tải lên vào thư mục có tên là hình ảnh. Thư mục có tên hình ảnh được lưu vào thư mục WAMP hoặc XAMPP có trong C Drive vào thư mục WWW.

Kết hợp các mã trên: Mã cuối cùng tải hình ảnh lên MySQL bằng Php được theo sau. & NBSP; & NBSP; The final code of upload the image into MySQL using PHP is as followed. 
 

  • Chương trình: Tên tệp: index.php Tệp này kết hợp mã HTML và PHP. & Nbsp; & nbsp; This file combines the HTML and PHP code. 
     

PHP

C:\wamp64\bin\apache\apache2.4.27\bin
64

C:\wamp64\bin\apache\apache2.4.27\bin
65
C:\wamp64\bin\apache\apache2.4.27\bin
66

C:\wamp64\bin\apache\apache2.4.27\bin
67
upload_max_size = 100M
post_max_filesize = 100M
29html0
upload_max_size = 100M
post_max_filesize = 100M
31

C:\wamp64\bin\apache\apache2.4.27\bin
71
C:\wamp64\bin\apache\apache2.4.27\bin
72___

Các

Các

____10

C:\wamp64\bin\apache\apache2.4.27\bin
96
upload_max_size = 100M
post_max_filesize = 100M
29
C:\wamp64\bin\apache\apache2.4.27\bin
98
C:\wamp64\bin\apache\apache2.4.27\bin
99
C:\wamp64\bin\apache\apache2.4.27\bin
78
upload_max_size = 100M
post_max_filesize = 100M
31

upload_max_size = 100M
post_max_filesize = 100M
003 0405060706html0061112

____1014

upload_max_size = 100M
post_max_filesize = 100M
2916
upload_max_size = 100M
post_max_filesize = 100M
31

____101903061412

____10

C:\wamp64\bin\apache\apache2.4.27\bin
71 26
C:\wamp64\bin\apache\apache2.4.27\bin
8706
C:\wamp64\bin\apache\apache2.4.27\bin
9630

<232 33

upload_max_size = 100M
post_max_filesize = 100M
31

____103637 38

<232 41

upload_max_size = 100M
post_max_filesize = 100M
31

upload_max_size = 100M
post_max_filesize = 100M
0
upload_max_size = 100M
post_max_filesize = 100M
54

upload_max_size = 100M
post_max_filesize = 100M
54

upload_max_size = 100M
post_max_filesize = 100M
45

<31

<32

upload_max_size = 100M
post_max_filesize = 100M
0<34

upload_max_size = 100M
post_max_filesize = 100M
0<36
C:\wamp64\bin\apache\apache2.4.27\bin
1 <38__

<43

<44

upload_max_size = 100M
post_max_filesize = 100M
0<46<0>

<2<50<7 <52html0 <54html3>

html5<58html8

C:\wamp64\bin\apache\apache2.4.27\bin
0>0>

>2<64html8

C:\wamp64\bin\apache\apache2.4.27\bin
0>7 <38__

html5<76

html5<58html8

C:\wamp64\bin\apache\apache2.4.27\bin
0>0>

>2<84html8

C:\wamp64\bin\apache\apache2.4.27\bin
0__94

html5<76

<2<96

upload_max_size = 100M
post_max_filesize = 100M
0<76

upload_max_size = 100M
post_max_filesize = 100M
0<46
upload_max_size = 100M
post_max_filesize = 100M
21>

<2

C:\wamp64\bin\apache\apache2.4.27\bin
64

<2html06

upload_max_size = 100M
post_max_filesize = 100M
29
upload_max_size = 100M
post_max_filesize = 100M
30
upload_max_size = 100M
post_max_filesize = 100M
31

Các

<2html18 html19html20 html21html1130

<2

upload_max_size = 100M
post_max_filesize = 100M
45

html5html27html28>

<2

C:\wamp64\bin\apache\apache2.4.27\bin
64

<2

upload_max_size = 100M
post_max_filesize = 100M
54

<2

upload_max_size = 100M
post_max_filesize = 100M
45

upload_max_size = 100M
post_max_filesize = 100M
0<76

html38

html39

  • Đầu ra: Cuối cùng, bạn sẽ có thể tải hình ảnh lên cơ sở dữ liệu và hiển thị nó bằng cách tìm nạp chúng từ cơ sở dữ liệu. & NBSP; Finally, you should be able to upload the images to the database and display it by fetching them from the database.
     

Hướng dẫn how to insert image in mysql database using phpmyadmin - cách chèn hình ảnh vào cơ sở dữ liệu mysql bằng phpmyadmin

đầu ra

Kết luận: Hình ảnh được tải lên vào cơ sở dữ liệu với mã PHP rất đơn giản và được sử dụng cho các mục đích khác nhau. Mã này giúp tải lên hình ảnh và sau đó tải hình ảnh vào cơ sở dữ liệu và có thể được hiển thị trong một thư mục khác. Một điều bạn nên lưu ý là khi bạn đang chạy chương trình này, có khả năng hình ảnh không được tải lên nhiều hơn 2 MB vì ​​chương trình PHP đã đặt giá trị mặc định của việc tải lên hình ảnh 2 MB và đăng hình ảnh 8 MB. Để vượt quá kích thước tải lên hình ảnh, bạn nên làm theo các bước sau: & nbsp; The uploaded image into the database with the PHP code is simple and used for various purposes. The code helps to upload the image and then uploaded the image into the database and can be shown in another folder.
One thing you should note is that when you are running this program there should be a possibility that the image is not uploaded more than 2 MB because the PHP program has set the default value of uploading an image of 2 MB and posting the image of 8 MB. For exceeding the size of uploading the image you should follow the following steps:
 

  • Đầu tiên, mở ổ C, sau đó mở thư mục WAMP hoặc XAMPP Server.
  • Sau đó mở thư mục bin.bin folder.
  • Mở thư mục phiên bản PHP (thư mục PHP 5.6.31) (vui lòng lưu ý rằng nếu bạn có phiên bản PHP khác, bạn cũng nên mở nó)
  • Sau đó tìm kiếm php.ini. Mở nó và sau đó tìm kiếm hai biến và thay đổi với chúng. Các biến là: & nbsp; & nbsp;php.ini. Open it and then search the two variables and change with them. The variables are: 
     
upload_max_size = 100M
post_max_filesize = 100M
  • Lưu với sự thay đổi này và sau đó mở & nbsp;
C:\wamp64\bin\apache\apache2.4.27\bin
  • và tìm kiếm tệp php.ini. Thay đổi điều tương tự mà ở trên đề cập.php.ini file. Change the same thing which is above mention.
  • Khởi động lại máy chủ WAMP hoặc XAMPP và sau đó chạy mã.

PHP là ngôn ngữ kịch bản phía máy chủ được thiết kế dành riêng cho phát triển web. Bạn có thể học PHP từ đầu bằng cách làm theo hướng dẫn PHP và các ví dụ PHP này.


Tôi có thể thêm hình ảnh trong cơ sở dữ liệu mysql không?

1 câu trả lời.Bạn có thể thử mã dưới đây để chèn một hình ảnh: chèn vào các giá trị xx_blob (id, hình ảnh) (1, load_file ('e: /images/jack.jpg'));INSERT INTO xx_BLOB(ID,IMAGE) VALUES(1,LOAD_FILE('E:/Images/jack. jpg'));

Làm cách nào để hiển thị hình ảnh trong cơ sở dữ liệu MySQL?

Chèn tệp hình ảnh trong MySQL.MySQL có kiểu dữ liệu BLOB (đối tượng lớn nhị phân) có thể chứa một lượng lớn dữ liệu nhị phân.....
Tạo bảng cơ sở dữ liệu.....
Cấu hình cơ sở dữ liệu (dbconfig.php) ....
Hình ảnh tải lên mẫu.....
Lưu trữ tệp hình ảnh trong cơ sở dữ liệu (tải lên. ....
Truy xuất hình ảnh từ cơ sở dữ liệu (Xem. ....
Conclusion..

Kiểu dữ liệu nào được sử dụng cho hình ảnh trong phpmyadmin?

Trong MySQL, loại dữ liệu ưa thích để lưu trữ hình ảnh là Blob.BLOB.

Làm thế nào để bạn chèn hình ảnh vào MySQL và hiển thị chúng bằng PHP?

-Biểu mẫu này là người dùng để hiển thị tất cả các hình ảnh-> RETRIVE tất cả các hình ảnh: