Or the image upload and display problem. Whether the image upload display problem is still the image upload display problem, the improved image still cannot display upload. php: storebinarydata‑sqldatabaseif (isset ($ _ POST [submit]) {$ fo or image upload and display problems
Still, the image cannot be displayed after being improved.
Upload. php:
Store binary data into SQL Database
If (isset ($ _ POST ['submit ']) {
$ Form_description = $ _ POST ['form _ description'];
$ Form_data_name = $ _ FILES ['form _ data'] ['name'];
$ Form_data_size = $ _ FILES ['form _ data'] ['size'];
$ Form_data_type = $ _ FILES ['form _ data'] ['type'];
$ Form_data = $ _ FILES ['form _ data'] ['tmp _ name'];
$ Connect = MYSQL_CONNECT ("localhost", "root", "123") or die ("Unable to connect to MySQL server ");
Mysql_select_db ("db_database18") or die ("Unable to select database ");
$ Data = addslashes (fread (fopen ($ form_data, "r"), filesize ($ form_data )));
$ Result = MYSQL_QUERY ("insert into ccs_image (description, bin_data, filename, filesize, filetype) VALUES ('$ form_description', '$ data',' $ form_data_name ', '$ form_data_size', '$ form_data_type ')");
$ Id = mysql_insert_id ();
Print"
This file has the following Database ID:$ Id";
MYSQL_CLOSE ();
} Else {
?>
}
?>
Imglist. php
$ Connect = MYSQL_CONNECT ("localhost", "root", "123") or die ("Unable to connect to MySQL server ");
Mysql_select_db ("db_database18") or die ("Unable to select database ");
$ Result = mysql_query ("SELECT * FROM ccs_image") or die ("Can't Perform Query ");
While ($ row = mysql_fetch_object ($ result )){
Echo "id." '>
";
}
?>
Show. php
If (isset ($ _ GET ['id']) {
$ Id = $ _ GET ['id'];
$ Connect = MYSQL_CONNECT ("localhost", "root", "sa") or die ("Unable to connect to MySQL server ");
Mysql_select_db ("test") or die ("Unable to select database ");
$ Query = "select bin_data, filetype from ccs_image where id =". $ id;
$ Result = @ MYSQL_QUERY ($ query );
$ Data = @ MYSQL_RESULT ($ result, 0, "bin_data ");
$ Type = @ MYSQL_RESULT ($ result, 0, "filetype ");
Header ("Content-type: $ type ");
Echo $ data;
}
?>
Let me answer
Website construction and solution
Resolved
Website construction and solution
For non-production systems, it is recommended to display all error messages.
Website construction and solution
Why? Share the result...
Upload or image upload display problems. after improvement, the image still cannot be displayed as upload. php: Store binary data into SQL Database if (isset ($ _ POST ['submit ']) {$ fo...