id.">

Home >Backend Development >PHP Tutorial >Or is there a problem with image upload and display_PHP Tutorial

Or is there a problem with image upload and display_PHP Tutorial

WBOY
WBOYOriginal
2016-07-13 10:52:30772browse




Or is there a problem with image upload display



It’s still a display problem when uploading images. After improvements, the images still can’t be displayed

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 "Or is there a problem with image upload and display_PHP Tutorial
";
}
?>



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 ideas and solutions
Solved

Website ideas and solutions
For non-production systems, it is recommended to display all error messages.

Website ideas and solutions
What's the reason? Share the results. . .


www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/632506.htmlTechArticleIs it still a problem with image upload display or image upload display problem? After improvement, the image still cannot be displayed upload.php: Store binary data into SQL Database if (isset($_POST['submit'])) { $fo...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn