【发布时间】:2017-01-24 09:40:24
【问题描述】:
我正在尝试从用户那里获取图像并将其保存在数据库中,但它给出了以下通知:
注意:取消定义索引 :u_pic in ...
<input type="file" name ="u_pic" class="file" style="margin-top: 10px;margin-left:10%;margin-right: 10%;width: 80%">
$image=addslashes(file_get_contents($_FILES['u_pic']['temp_name']));
$insert = "insert into users (profilepicture) values ('$image' )";
【问题讨论】:
-
您是否在表单中添加了 enctype='multipart/form-data' 这个?
-
在这里发布您的 php 和 html 代码!是的,它没有获取文件输入的索引或名称
-
$_FILES['u_pic']['temp_name']这完全正确吗? -
不要将文件保存在数据库中。 stackoverflow.com/a/41235395/267540
-
尝试 print_r($_FILES) 以查看您的表单提交文件是否值您想要服务器的值