title: "Undefined index" when uploading image using php
body: <p>I have this form:</p>
  
  <pre><code>&lt;form action="image_upload.php" method="post" enctype="multipart/form-data"&gt;
     Image 1: &lt;input type="file" name="event_image" /&gt;
     &lt;input type="submit" /&gt;
  &lt;/form&gt; 
  </code></pre>
  
  <p>and this php code (image_upload.php):</p>
  
  <pre><code>print_r($_FILES);
  if ((($_FILES["event_image"]["type"] == "image/jpeg")
  || ($_FILES["event_image"]["type"] == "image/pjpeg"))
  &amp;&amp; ($_FILES["event_image"]["size"] &lt; 200000))
    {
    if ($_FILES["event_image"]["error"] &gt; 0)
      {
      echo "Return Code: " . $_FILES["event_image"]["error"] . "&lt;br /&gt;";
      }
    else
      {
      if (file_exists("/images/events/" . $_FILES["event_image"]["name"]))
        {
        echo $_FILES["event_image"]["name"] . " already exists. ";
        }
      else
        {
        move_uploaded_file($_FILES["event_image"]["tmp_name"],
        "/images/events/" . $_FILES["event_image"]["name"]);
        echo "Stored in: " . "upload/" . $_FILES["event_image"]["name"];
        }
      }
    }
  else
    {
    echo "Invalid file";
    }
  </code></pre>
  
  <p>I have no idea where this is going wrong as I've had the same code working before. </p>
  
  <p>I am getting the following error though...</p>
  
  <p>Array ( [event_image] => Array ( [name] => my_image.jpg [type] => image/jpeg [tmp_name] => /private/var/tmp/phpvIYmAZ [error] => 0 [size] => 48512 ) ) </p>
  
  <p>Warning: move_uploaded_file(../../../images/events/my_image.jpg): failed to open stream: Permission denied in /path/event_upload.php on line 25 </p>
  
  <p>Warning: move_uploaded_file(): Unable to move '/private/var/tmp/phpvIYmAZ' to '../../../images/events/my_image.jpg' in /path/event_upload.php on line 25 Stored in: upload/my_image.jpg </p>
  
  <p>Notice: Undefined index: event_image in /path/event_upload.php on line 57</p>