无限上传文件一次在php


Unlimited upload files at once in php

我使用这个php代码一次上传多个文件,问题是我只能上传20个文件,只有我不能一次上传多个文件

php代码

<?php
include("../includes/connect.php");
if (strtolower($_SERVER['REQUEST_METHOD']) !== 'post') header('Location:test.php');
date_default_timezone_set('Asia/Beirut');
$date=date('Y-m-d H:i:s');
$username=$_SESSION['user'];
$parentID = !empty($_GET['parentID']) ? $_GET['parentID'] : 0;;
$parent_id=intval($_GET['parentID']);
$valid_formats = array("jpg", "png", "gif", "zip","PNG","jpeg","bmp","pdf", "doc", "docx","xlsx","xls","txt","csv","pptx","ppt","pptm","dwg","rtf");
$max_file_size = 1024*100; //100 kb
$path = "../uploads_images/"; // Upload directory
$count = 0;
if(isset($_POST) and $_SERVER['REQUEST_METHOD'] == "POST"){
    // Loop $_FILES to exeicute all files
    foreach (preg_replace('/ /','-',($_FILES['myfile']['name'])) as $f => $name) {     
        if ($_FILES['myfile']['error'][$f] == 4) {
           continue; // Skip file if any error found
        }          
        if ($_FILES['myfile']['error'][$f] == 0) {             
            if( ! in_array(pathinfo($name, PATHINFO_EXTENSION), $valid_formats) ){
                $message[] = "$name is not a valid format";
                continue; // Skip invalid file formats
            }
            else{ // No error found! Move uploaded files $sql=mysqli_query($conn,"select name from tbl_files where name='$name'")or die(mysqli_error($conn));
                $countfile=mysqli_num_rows($sql);
                if($countfile==0){
         if(move_uploaded_file($_FILES["myfile"]["tmp_name"][$f], $path.$name))
$query=mysqli_query($conn,"INSERT INTO tbl_files(name,parent_id,db_username,db_date,db_isdeleted)VALUES('$name','$parent_id','$username','$date','0')") or die(mysqli_error($conn));
                $count++; // Number of successfully uploaded file
                header("location:dms.php?parentID=$parent_id&view");
                }else{header("location:dms.php?parentID=$parent_id&msg=3&view");}
            }
        }
    }
}       
    ?>

谷歌后,我发现我需要改变upload_max_filesize我这样做了,我改变了1G这样upload_max_filesize=1G,但同样的问题仍然存在php.ini

memory_limit = 256

post_max_size = 1 g

upload_max_filesize = 64

我使用的主机和域名在godaddy

最后的问题是我如何解决我的问题,可以一次上传无限的文件?

change

max_file_uploads=20

到你想要的任何数字。如

max_file_uploads=200

别忘了重启服务器