0

I was wondering if anyone could help me figure out how to add the following

  • multi-file drag and drop feature and to log the location of each file after upload using the below
  • "echo "Uploaded to: " . "localhost/site/uploads/" . $_FILES['uploaded_file']["name"];"
  • file size limitation to 100MB
  • The bonus feature is to have an HTML select multiple Attribute to choose other folders to upload in for example, the current folder is "upload" but I'd like to have another 3 as options to upload into it
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Manual file upload</title>
  <link rel="stylesheet" href="style.css">
</head>


<body>

<div class="area">
  <form enctype="multipart/form-data" action="index.php" method="POST">
    <p>Upload your file</p>
    <input class="button1" type="file" multiple="multiple" name="uploaded_file"></input><br/>
    <input class="button2" type="submit" value="Upload"></input>
  </form>
</div>

<?PHP
   if(!empty($_FILES['uploaded_file']))
   {
     $path = "uploads/";
     $path = $path . basename( $_FILES['uploaded_file']['name']);

     if(move_uploaded_file($_FILES['uploaded_file']['tmp_name'], $path)) {
       echo "Uploaded to: " . "loclahost/site/uploads/" . $_FILES['uploaded_file']["name"];
     } else{
         echo "There was an error uploading the file, please try again!";
     }
   }

?> 

</body>
</html>
Greedo
  • 3,438
  • 1
  • 13
  • 28
  • Yes it's all possible, what you have try? – Simone Rossaini Jul 07 '20 at 12:12
  • Apologize, Here is what I got so far and I'd like to add the features I have mentioned – Samual Khan Jul 07 '20 at 12:16
  • [Limit size of upload](https://stackoverflow.com/questions/5697605/limit-the-size-of-an-file-upload-html-input) + [Multi drag and drop](https://stackoverflow.com/questions/10779730/multiple-image-uploads-display-all-drag-drop-from-all) Just use **Search** at the top of the page. For the last you can use simple select box then use this value in php for change folder. – Simone Rossaini Jul 07 '20 at 12:20

1 Answers1

0

you just need to add select box in it. for ex.

<select name="folder_name">
      <option value="upload">Uploads</option>
      <option value="upload1">Uploads 1</option>
      <option value="upload2">Uploads 2</option>
</select>

in php:

  $path = $_POST['folder_name'];     // instead of static - $path = "uploads/";

on every file uploading you can change the path if not it will select the default value of select box. you can change the name of the folder as your need. I think this will solve your problem.