如何使用PHP源代码在mysql数据库中插入图像..? [英] How to insert image in mysql database using PHP source code..?
问题描述
<?php
mysql_connect(localhost,root,)或死掉(无法连接到服务器);
mysql_select_db (demodemo)或死亡(无法找到该数据库);
$ file = $ _FILES ['image'] ['tmp_name'];
$ image = addslashes(file_get_contents($ _ FILES ['image'] ['tmp_name']));
$ image_name = addslashes ($ _FILES ['image'] ['name']);
$ image_size = getimagesize($ _ FILES ['image'] ['tmp_name']);
mysql_query(INSERT INTO image(id,image)VALUES('1','{$ image}'));
?>
我的尝试:
i有一个尝试..
<?php
mysql_connect(localhost ,root,或死(无法连接到服务器);
mysql_select_db(demodemo)或死(无法找到该数据库); < br $>
$ file = $ _FILES ['image'] ['tmp_name'];
$ image = addslashes(file_get_contents($ _ FILES ['image'] ['tmp_name']));
$ image_name = addslashes($ _ FILES ['image'] ['name']);
$ image_size = getimagesize($ _ FILES ['image'] ['tmp_name']);
mysql_query(INSERT INTO image(id,image) VALUES('1','{$ image}'));
?>
<?php
mysql_connect("localhost", "root","") or die ("could not connect to the server");
mysql_select_db("demodemo") or die ("that database could not be found");
$file = $_FILES['image']['tmp_name'];
$image= addslashes(file_get_contents($_FILES['image']['tmp_name']));
$image_name = addslashes($_FILES['image']['name']);
$image_size = getimagesize($_FILES['image']['tmp_name']);
mysql_query("INSERT INTO image (id,image) VALUES ('1','{$image}')");
?>
What I have tried:
i have a tried..
<?php
mysql_connect("localhost", "root","") or die ("could not connect to the server");
mysql_select_db("demodemo") or die ("that database could not be found");
$file = $_FILES['image']['tmp_name'];
$image= addslashes(file_get_contents($_FILES['image']['tmp_name']));
$image_name = addslashes($_FILES['image']['name']);
$image_size = getimagesize($_FILES['image']['tmp_name']);
mysql_query("INSERT INTO image (id,image) VALUES ('1','{$image}')");
?>
推荐答案
file =
_FILES ['image'] ['tmp_name '];
_FILES['image']['tmp_name'];
image = addslashes(file_get_contents(
image= addslashes(file_get_contents(
这篇关于如何使用PHP源代码在mysql数据库中插入图像..?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!