[英]Cant store the image to the database using php
I am trying to upload an image in my database from HTML form.我正在尝试从 HTML 表单上传我的数据库中的图像。 I have written the PHP code and I have an error message
我已经编写了 PHP 代码,但有一条错误消息
<form action="login.php" method="post" enctype="multipart/form-data">
user<input type="text" name="user_name1" required />
password<input type="password" name="password1" required />
Email<input type="email" name="email11" required />
Upload any image you want<input type="file" name="image">
<input class="submit" type="submit" name="submit2" value="sign up"/>
</form>
and this is the PHP code这是 PHP 代码
<?php
if(array_key_exists('submit2',$_POST))
{
$user=$_POST['user_name1'];
$pass=$_POST['password1'];
$email=$_POST['email11'];
$image=addcslashes($_FILES['image']['tmp_name']);
$image_name=addcslashes($_FILES['image']['name']);
$image2=file_get_contents($image);
$image3=base64_encode($image2);
$query9="insert into login values('$user','$pass','$email','$image3','$image_name')";
if(mysqli_query($conn,$query9))
echo "Insert is successful";
else
echo "Error ".$query9."<br>".mysqli_error($conn);
}
mysqli_close($conn);
?>
This is the error I get after executing the code这是我执行代码后得到的错误
Warning: addcslashes() expects exactly 2 parameters, 1 given in
警告:addcslashes() 需要 2 个参数,1 个在
You are using addcslashes which requires 2 parameters, the first being the string, and the second, a list of characters you want to escape.您正在使用addcslashes ,它需要 2 个参数,第一个是字符串,第二个是要转义的字符列表。
I believe you want to use addslashes which will return your string with backslashes before characters that need to be escaped.我相信你想使用addslashes ,它会在需要转义的字符之前返回带有反斜杠的字符串。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.