首页 > 解决方案 > 请帮助:如果 isset 在上传多个文件时不起作用

问题描述

我尝试上传多个文件我使用了很多脚本来上传它工作正常但有时有些文件没有上传我检查了问题

当我选择所有图像时,我有一个包含图像的文件单击提交时我没有得到任何响应

当我选择所有文件时,我只想让它说(嗨),这样我就可以知道它在上传时到达了我的代码。

<?php  /* and also checked by : */

if (isset($_POST['btnsubmit'])) {  
    echo "hi"; 
}

/* it's not working when i select all the images in once and click submit to check */

if(isset($_FILES['files']['name'])) {  
    echo "Hii"; 
}  // it's not working when i select all the files            
?>

<html>
<head></head>
<body>
<form id="myForm" name="myForm" action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post" 
    enctype="multipart/form-data"   >


    <table width="100%">
        <tr>
            <td>Select Photo (one or multiple):</td>
            <td><input type="file" accept="image/gif, image/jpeg, image/png" name="files[]" 
                multiple="multiple" required /></td>
        </tr>
        <tr>
            <td colspan="2" align="center">Note: Supported image format: .jpeg, .jpg, .png, .gif</td>
        </tr>
        <tr>
            <td colspan="2" align="center">
                <input type="submit" name="btnsubmit" 
                value="Submit" id="btnsubmit"/></td>
        </tr>
    </table>
</form>

</body>
</html>

标签: phphtml

解决方案


通过添加解决了

exit;

到 php 代码。

不管怎么说,还是要谢谢你 。


推荐阅读