I tried using some file input in a form for uploading several different file types and when clicking on the submit button then file multiple files are stored in a mysql table . the problem is when clicking the sumbit it will display an error: "Warning : in_array ( ) expects at most 3 parameters , 5 given in....". when I use one input file , the file was successfully uploaded to the server folder . and this is the code I used :
$dir = $name;
$target_dir = "my-file/$dir/";
if( is_dir($target_dir) === false )
{
mkdir($target_dir);
}
if(isset($_POST["submit"])) {
$formatfilea = array("pdf");
$formatfileb = array("pdf");
$formatfilec = array("pdf");
$formatfiled = array("jpg, jpeg");
$filea = $_FILES['filea']['name'];
$fileb = $_FILES['fileb']['name'];
$filec = $_FILES['filec']['name'];
$filed = $_FILES['filed']['name'];
$xa = explode('.', $filea);
$xb = explode('.', $fileb);
$xc = explode('.', $filec);
$xd = explode('.', $filed);
$existencea = strtolower(end($xa));
$existenceb = strtolower(end($xb));
$existencec = strtolower(end($xc));
$existenced = strtolower(end($xd));
$sizea = $_FILES['filea']['size'];
$sizeb = $_FILES['fileb']['size'];
$sizec = $_FILES['filec']['size'];
$sized = $_FILES['filed']['size'];
$file_tmp_a = $_FILES['filea']['tmp_name'];
$file_tmp_b = $_FILES['fileb']['tmp_name'];
$file_tmp_c = $_FILES['filec']['tmp_name'];
$file_tmp_d = $_FILES['filed']['tmp_name'];
if(in_array($existencea, $formatfilea && $existenceb, $formatfileb && $existencec, $formatfilec && $existenced, $formatfiled) === true){
if($sizea < 1044070 && $sizeb < 1044070 && $sizec < 1044070 && $sized < 1044070){
move_uploaded_file($file_tmp_a, $target_dir.$filea);
move_uploaded_file($file_tmp_b, $target_dir.$fileb);
move_uploaded_file($file_tmp_c, $target_dir.$filec);
move_uploaded_file($file_tmp_d, $target_dir.$filed);
} else {
}
}
}
// attempt insert query execution
$sql = "INSERT INTO test (filea, fileb, filec, filed) VALUES ('$filea', '$fileb', '$filec', '$filed')";
is there who can help me provide a solution? What causes this error? and why I uploaded file is not found on the file server?