我想从我的电脑上传img到我的网站。当我点击输入类型"file“时,我可以添加img,我可以看到它的名称。但当我点击上传“请添加图像”显示。
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">发布于 2020-03-28 07:59:42
试着改变
<form method="post" action="" class="edit_profile">至
<form method="post" action="" class="edit_profile" enctype="multipart/form-data"> https://stackoverflow.com/questions/60895662
复制相似问题