$_FILES['uploadImg']['name'] 点击提交按钮后找不到
$_FILES['uploadImg']['name'] can't be found after clicked on submit button
我想从我的电脑上传 img 到我的网站。当我点击输入类型 "file" 时,我可以添加 img 并且可以看到它的名称。但是当我点击上传时 "please add image" 显示。
if (!empty($_POST["uploadImg"])) {
echo "button was clicked! "
if (!empty($_FILES['profileImg']['name'])) {
echo "it works!!!";
} else {
echo "please add image";
}}
HTML:
<form method="post" action="" class="edit_profile">
<!-- profielfoto -->
<img src="<?php echo "none"; //$profile[1]['image_name']
?>" alt="Profielfoto">
<input type="file" name="profileImg" id="profileImg" class="new_avatar" accept="image/gif, image/jpeg, image/png, image/jpg">
<!--button-->
<input type="submit" name="uploadImg" class="btn" value="Upload Image">
尝试改变
<form method="post" action="" class="edit_profile">
至
<form method="post" action="" class="edit_profile" enctype="multipart/form-data">
我想从我的电脑上传 img 到我的网站。当我点击输入类型 "file" 时,我可以添加 img 并且可以看到它的名称。但是当我点击上传时 "please add image" 显示。
if (!empty($_POST["uploadImg"])) {
echo "button was clicked! "
if (!empty($_FILES['profileImg']['name'])) {
echo "it works!!!";
} else {
echo "please add image";
}}
HTML:
<form method="post" action="" class="edit_profile">
<!-- profielfoto -->
<img src="<?php echo "none"; //$profile[1]['image_name']
?>" alt="Profielfoto">
<input type="file" name="profileImg" id="profileImg" class="new_avatar" accept="image/gif, image/jpeg, image/png, image/jpg">
<!--button-->
<input type="submit" name="uploadImg" class="btn" value="Upload Image">
尝试改变
<form method="post" action="" class="edit_profile">
至
<form method="post" action="" class="edit_profile" enctype="multipart/form-data">