如何统计上传文件的数量?这是我的表格:
<div id="dragAndDropFiles" class="uploadArea">
<h1>Drop Images Here</h1>
</div>
<form id="sfmFiler" class="sfmform" method="post" enctype="multipart/form-data">
<input type="file" name="file" id="file" multiple />
<input type="submit" name="submitHandler" id="submitHandler" class="buttonUpload" value="Upload">
</form>这是上传文件的php片段:
if($_SERVER['REQUEST_METHOD'] == "POST") {
$tmpFilePath = $_FILES['file']['tmp_name'];
$newFilePath = $dir.'/' . $_FILES['file']['name'];
if(move_uploaded_file($tmpFilePath, $newFilePath)) {
echo "xxx files are successfully uploaded";
}
} 发布于 2016-05-21 21:31:25
在这段代码中,你只得到一个文件,这就是为什么你会得到计数结果1.如果你的输入文件名改为"file[]“
<input type="file" name="file[]" id="file" multiple />然后使用下面的代码,你会得到你想要的结果。因为它需要一个数组字段来保存输入数据。
<?php echo count($_FILES['file']['name']); ?>谢谢,我试着在我的系统中得到了结果。
https://stackoverflow.com/questions/37363231
复制相似问题