Answers for "php mutiple file upload"

PHP
2

php upload multiple files

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>TEST</title>
</head>
<body>
    <form autocomplete="off" method="post" action="" enctype="multipart/form-data">
        <input id="file" name="file[]" type="file" multiple="multiple">
        <button name="submit" type="submit">Senden</button>
    </form>
</body>
</html>
<?php 
    if(isset($_POST['submit'])){

        for($i = 0; $i < count($_FILES['file']['name']);$i++){
          $f_maxsize = 41943040;
          $f_ext_allowed = array("stl", "STL", "jpeg", "png", "gif");

          $f_name_2 = str_replace(" ","_", htmlspecialchars($_FILES["file"]['name'][$i]));
          $f_size  =  $_FILES["file"]['size'][$i];
          $f_tmp   =  $_FILES["file"]['tmp_name'][$i];
          $f_error =  $_FILES["file"]['error'][$i];
          $f_ext = pathinfo($f_name_2, PATHINFO_EXTENSION);

          # Check the file for errors etc...

          move_uploaded_file($f_tmp, "to/upload/directory/" . $_FILES["file"]['name'][$i]);

        }
    }
?>
Posted by: Guest on September-03-2021

Browse Popular Code Answers by Language