title: php file upload array sum
body: <p>hey I keep getting the error  </p>
  
  <blockquote>
    <p>array_sum() expects parameter 1 to be array</p>
  </blockquote>
  
  <p>Does anyone know what I am doing wrong? Thanks a ton. I think i may have a slash in the wrong spot on a folder name or something? I have a drop down menu giving me the value for the folder and am submitting my form through javascript like so:</p>
  
  <pre><code>document.getElementById("form").submit();
  alert("form submitted");
  </code></pre>
  
  <p>PHP</p>
  
  <pre><code>&lt;?php
  $type = $_POST['Folder'];
  $folder = "uploaded/$type";
  $allow_types=array("aiff","mp3","wav");
  $max_combined_size="10000";
  
  If($_POST['submit']==true) {
  
      //Tally the size of all the files uploaded, check if it's over the ammount. 
      If(array_sum($_FILES['file']['size']) &gt; $max_combined_size*1024) {
  
          echo "Combined file size is to large";
  
          / Loop though, verify and upload files.
      } Else {
          // Loop through all the files.
          For($i=0; $i &lt;= $file_uploads-1; $i++) {
              //Get the file extension
              $file_ext[$i] = strtolower(pathinfo($_FILES['file']['name'][$i], PATHINFO_EXTENSION));
              // If the file is a file
              If($_FILES['file']['name'][$i]) {
                  // Randomize file names
  
                  $file_name[$i]=1;
                  while(1){
                      $file_name[$i] =$file_name[$i]+1;
                      if exists("$folder/$file_name[$i].$file_ext[$i]")){ 
                          break;
                      }
                  }
  
                  // Check for blank file name
                  If(str_replace(" ", "", $file_name[$i])=="") {      
                      echo " Blank file name detected";
                  } ElseIf(!in_array($file_ext[$i], $allow_types)) {
                      echo "Invalide file type";
                  } Elseif(file_exists($folder.$file_name[$i].".".$file_ext[$i])) {
  
                      echo "File already exists";
  
                  } Else {
  
                      If(move_uploaded_file($_FILES['file']['tmp_name'][$i],$folder.$file_name[$i].".".$file_ext[$i])) {
                          echo "success!";    
                      } Else {
                          echo "upload failure";
                      }
                  }
              } // If Files
          } // For
      } // Else Total Size 
  }
  ?&gt; 
  </code></pre>