title: How can I upload a zip file using php?
body: <p>I want people to be able to upload zip files to my server. I have a form for them to upload to and it redirects to an upload page. I can successfully upload pictures (png and jpg) but whenever I try a zip I get several "undefined index errors on lines 4-8." Here is my code. If you want to check out the website, it should be available at <a href="http://gregsminecraft.dyndns.org:25566/file.php" rel="nofollow">gregsminecraft.dyndns.org:25566/file.php</a> EDIT: I believe that it doesn't accept the large zip file, because I tried it with a smaller one and it worked. Is there a way to accept the larger zip files?</p>
  
  <pre><code> if ((($_FILES["file"]["type"] == "application/zip")
  || ($_FILES["file"]["type"] == "application/x-zip-compressed")
  || ($_FILES["file"]["type"] == "multipart/x-zip")
  || ($_FILES["file"]["type"] == "application/x-compressed")
  || ($_FILES["file"]["type"] == "application/octet-stream"))
  &amp;&amp; ($_FILES["file"]["size"] &lt; 20971520))
    {
    if ($_FILES["file"]["error"] &gt; 0)
      {
      echo "Return Code: " . $_FILES["file"]["error"] . "&lt;br /&gt;";
      }
    else
      {
      echo "Upload: " . $_FILES["file"]["name"] . "&lt;br /&gt;";
      echo "Type: " . $_FILES["file"]["type"] . "&lt;br /&gt;";
      echo "Size: " . ($_FILES["file"]["size"] / 1024) . " Kb&lt;br /&gt;";
      echo "Temp file: " . $_FILES["file"]["tmp_name"] . "&lt;br /&gt;";
  
      if (file_exists("upload/" . $_FILES["file"]["name"]))
        {
        echo $_FILES["file"]["name"] . " already exists. ";
        }
      else
        {
        move_uploaded_file($_FILES["file"]["tmp_name"],
        "upload/" . $_FILES["file"]["name"]);
        echo "Stored in: " . "upload/" . $_FILES["file"]["name"];
        }
      }
    }
  else
    {
    echo "Invalid file";
    }
  </code></pre>