title: Multiple file upload with php and html
body: <p>I'm having trouble implementing this script for multiple file uploads. The user needs to specify exactly which folder (Course Code) to put the file in hence the $_POST function</p>
  
  <p>Here is my HTML</p>
  
  <pre><code>&lt;form enctype="multipart/form-data" action="uploader.php" method="POST"&gt;
     Choose Course Code:
     &lt;select name="subject_list"&gt;
          &lt;option value="ACC 100"&gt;ACC 100&lt;/option&gt;
          &lt;option value="ACC 406"&gt;ACC 406&lt;/option&gt;
          &lt;option value="ECN 104"&gt;ECN 104&lt;/option&gt;
          &lt;option value="ECN 204"&gt;ECN 204&lt;/option&gt;
          &lt;option value="FIN 300"&gt;FIN 300&lt;/option&gt;
          &lt;option value="GMS 200"&gt;GMS 200&lt;/option&gt;
          &lt;option value="ITM 100"&gt;ITM 100&lt;/option&gt;
          &lt;option value="ITM 301"&gt;ITM 301&lt;/option&gt;
          &lt;option value="ITM 305"&gt;ITM 305&lt;/option&gt;
          &lt;option value="ITM 330"&gt;ITM 330&lt;/option&gt;
          &lt;option value="ITM 350"&gt;ITM 350&lt;/option&gt;
          &lt;option value="ITM 407"&gt;ITM 407&lt;/option&gt;
          &lt;option value="ITM 500"&gt;ITM 500&lt;/option&gt;
          &lt;option value="ITM 501"&gt;ITM 501&lt;/option&gt;
          &lt;option value="ITM 505"&gt;ITM 505&lt;/option&gt;
          &lt;option value="ITM 600"&gt;ITM 600&lt;/option&gt;
          &lt;option value="LAW 122"&gt;LAW 122&lt;/option&gt;
          &lt;option value="SSH 105"&gt;SSH 105&lt;/option&gt;
          &lt;option value="Other"&gt;Other&lt;/option&gt;
     &lt;/select&gt;
      &lt;br&gt;
     Choose a file to upload (Max 500MB): &lt;input name="rye_file[]" type="file" id="file_style" multiple /&gt;
      &lt;input type="submit" name="submit" value="Upload" /&gt;
  &lt;/form&gt; 
  
  &lt;form action="/logout.php"&gt;
     &lt;input type="submit" value="Logout"&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>Here is my PHP:</p>
  
  <pre><code>&lt;?php
     session_start();
  
      // IF USER NOT REMEMBERED(DID NOT CLICK REMEBER ME BUTTON) OR NO SESSION IS FOUND THEN THROW HIM OUT TO LOGIN
     //SECURITY SO THAT USERS CANT ACCESS WEB URL DIRECTLY
     if (!isset($_SESSION['myusername']) &amp;&amp; !isset($_COOKIE['myusername'])) {
          header("Location: index.php");
      }
  
     // SUBJECT_LIST IS FOR USER TO CHOOSE FOLDER
     $subject_list = $_POST['subject_list'];
     $uploaddir = "/var/www/fixnode_website/content/Secure Login/Rye High/uploads/$subject_list";
     $files=array();
     $fdata=$_FILES['rye_file'];
     if(is_array($fdata['name'])){
          for($i=0;$i&lt;count($fdata['name']);++$i){
              $files[]= array(
                              'name'     =&gt; $fdata['name'][$i],
                              'tmp_name' =&gt; $fdata['tmp_name'][$i],
                              );
          }
     } else $files[]=$fdata;
  
     foreach ($files as $file) {
        // uploaded location of file is $file['tmp_name']
        // original filename of file is $file['name']
          if (move_uploaded_file($file['tmp_name'], "$uploaddir/$file['name']")) {
              echo "File is valid, and was successfully uploaded.\n Please wait, your browser will refresh in 5-10 seconds!";
          } else {
              echo "Upload failed";
          }
     }
  ?&gt; 
  </code></pre>
  
  <p>I keep getting a Error 500 Server Error. If anyone can help modify my code to match my perameters then I will greatly appreciate it</p>
  
  <p>Thanks,
  Phillip Kujawa</p>