How can user-friendliness be maintained when allowing users to upload multiple files in PHP?
When allowing users to upload multiple files in PHP, user-friendliness can be maintained by providing clear instructions, error messages, and feedback throughout the upload process. Additionally, using a user-friendly interface with progress bars or status updates can help users track the upload progress of each file.
<?php
if(isset($_POST['submit'])){
$total = count($_FILES['upload']['name']);
for($i=0; $i<$total; $i++){
$file_name = $_FILES['upload']['name'][$i];
$file_tmp = $_FILES['upload']['tmp_name'][$i];
// Process file upload here
move_uploaded_file($file_tmp, "uploads/".$file_name);
}
echo "Files uploaded successfully!";
}
?>
<form method="post" enctype="multipart/form-data">
<input type="file" name="upload[]" multiple>
<input type="submit" name="submit" value="Upload Files">
</form>