如何使用PHP源代码在mysql数据库中插入图像..? [英] How to insert image in mysql database using PHP source code..?

查看:84
本文介绍了如何使用PHP源代码在mysql数据库中插入图像..?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

<?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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆