What are some potential issues with uploading multiple files in PHP using input fields?

One potential issue with uploading multiple files in PHP using input fields is that the files may overwrite each other if they have the same name. To solve this issue, you can append a unique identifier to each file name before uploading it.

// Loop through each uploaded file
foreach ($_FILES['file']['name'] as $key => $name) {
    $unique_id = uniqid(); // Generate a unique identifier
    $new_name = $unique_id . '_' . $name; // Append unique identifier to file name
    move_uploaded_file($_FILES['file']['tmp_name'][$key], 'uploads/' . $new_name); // Upload file with new name
}