【发布时间】:2018-08-28 18:28:11
【问题描述】:
我正在尝试上传要存储在 mysql 数据库中的图像,但是我一直收到错误消息:
注意:未定义的索引:profilepic in >[php-path]/tuto>rsignupsubmit.php on line 17
表单上有一个简单的上传类型文件的按钮:
<div class="field">
<label>Profile Picture</label>
<input class="button" type="file" name="profilepic">
</div>
然后我在另一个提交页面上有此代码,我对 PHP 很陌生,但是我已经搜索和搜索,但在任何地方都找不到解决方案。
//File upload
$target_dir = "../img/";
$newprofilepic = $target_dir . basename($_FILES ["profilepic"]["name"]);
$uploadOk = 1;
$imageFileType = strtolower(pathinfo($newprofilepic,PATHINFO_EXTENSION));
$newlocation = mysqli_real_escape_string($conn,$_POST['location']);
$insertquery = "INSERT INTO tutors(name, username, password, email, mobile,
profilepic, location,
message)"."VALUES('$newname','$newusername','$newpassword','$newemail',
'$newmobile', '$newprofilepic', '$newlocation', '$newmessage')";
$result = mysqli_query($conn, $insertquery) or die(mysqli_error($conn));
mysqli_close($conn);
提前致谢。
【问题讨论】:
-
我建议你做 var_dump($_FILES);以便查看您的服务器正在接收什么。
-
你能分享你的整个html代码吗??
标签: php mysql html file-upload