$ _ FILES ['uploadImg'] ['name']在单击提交按钮后找不到

问题描述 投票:0回答:1

我想将img从我的计算机上传到我的网站。当我单击输入类型“文件”时,我可以添加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">
php file post file-upload upload
1个回答
0
投票

尝试更改

<form method="post" action="" class="edit_profile">

to

<form method="post" action="" class="edit_profile" enctype="multipart/form-data">   
© www.soinside.com 2019 - 2024. All rights reserved.