【发布时间】:2016-10-31 12:13:16
【问题描述】:
我是 php 的菜鸟,我无法在 php 中显示图像数据。我尝试了 1 小时,但无法理解问题所在。请帮忙。
<?php
ini_set('mysql.connect_timeout',300);
ini_set('default_socket_timeout',300);
?>
<form method="post" enctype="multipart/form-data">
<br/>
<input type="file" name="image"/>
<br/><br/>
<input type="submit" name="submit" value="Upload"/>
</form>
<?php
if(isset($_POST['submit'])
{
$imagedata=mysql_real_escape_string(file_get_contents($_FILES["image"],["tmp_name"]));
echo $imagedata;
}
else
{
echo "there has been some error";
}
?>
</body>
【问题讨论】:
-
你这里有很多错误
-
请stop using
mysql_*functions。 These extensions 已在 PHP 7 中被删除。了解 PDO 和 @987654325 的 prepared 语句@ 并考虑使用 PDO,it's really pretty easy。 -
非常感谢,从现在开始我将在项目中使用 mysqli。我不知道 pdo 是什么,但我会用谷歌搜索它。再次感谢
-
@JohnConde 是的,我已经确定了他们。谢谢你:)