Reputation: 231
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
<?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");}
}
}
}
}
?>
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
memory_limit=256M
post_max_size=1G
upload_max_filesize=64M
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??!!
Upvotes: 2
Views: 2282
Reputation: 5501
change
max_file_uploads=20
to whatever number you want. Such as
max_file_uploads=200
Don't forgot to restart server.
Upvotes: 1