m7md m7md - 1 year ago 72
PHP Question

Unlimited upload files at once in php

I use this php code to upload multiple files at once the problem is i can only upload 20 files only i can't upload more than that at once

php code

if (strtolower($_SERVER['REQUEST_METHOD']) !== 'post') header('Location:test.php');
$date=date('Y-m-d H:i:s');
$parentID = !empty($_GET['parentID']) ? $_GET['parentID'] : 0;;
$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));
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


After googling i found i need to change upload_max_filesize i did this i changed to 1G like this upload_max_filesize=1G but also the same problem still
that what i change in php.ini




I'm using a hosting and domain in godaddy

Finally the question is How i solve my question and can be able to upload Unlimited files at once??!!

Answer Source



to whatever number you want. Such as


Don't forgot to restart server.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download