I did did code to upload many files. What I want to do now is to save the path for each file event when many files are uploaded at once. I am unly able to get the folder with the code at the bottom:
<?php
$valid_formats = array("jpg", "png", "gif", "zip", "docx","zip","pdf");
$max_file_size = 1024*100;
$path = "/uploads/$orderid/";
if ( ! is_dir($path)) {
mkdir($path);
}
$count = 0;
if(isset($_POST) and $_SERVER['REQUEST_METHOD'] == "POST"){
foreach ($_FILES['content']['name'] as $f => $name) {
if ($_FILES['content']['error'][$f] == 4) {
continue;
}
if ($_FILES['content']['error'][$f] == 0) {
if ($_FILES['content']['size'][$f] > $max_file_size) {
$message[] = "$name is too large!.";
continue; // Skip large files
}
elseif( ! 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
if(move_uploaded_file($_FILES["content"]["tmp_name"][$f], $path.$name))
$count++; // Number of successfully uploaded file
}
}
}
echo "<div>You have uploaded : ". $count."</div>";
}
$sql="INSERT INTO oz2ts_web_intake_files_folder (file_id, f_folder)
VALUES
('$orderid', '$path')";
?>