title: Uploading file using $_FILES and PHP
body: <p>Today I tried for the first time to upload files to my website, but it seems that it doesn't work. I hope someone can help me, and I hope my code is readable :)</p>
  
  <p>The problem is when I choose file and SUBMIT form it is not accepted because <code>$_FILES</code> is NULL</p>
  
  <pre><code>if (move_uploaded_file($_FILES['obrazok']['tmp_name'], $uploadfile))
  </code></pre>
  
  <p>UPDATED Error</p>
  
  <pre><code>Warning: move_uploaded_file(www_nekonomagic/res/img/anime/uploads/793392545Untitled.jpg): failed to open stream: No such file or directory in /home/gj020900/www_nekonomagic/admin/admin-nove-anime.php on line 107
  
  Warning: move_uploaded_file(): Unable to move '/home/gj020900/tmp/php9izgwb' to 'www_nekonomagic/res/img/anime/uploads/793392545Untitled.jpg' in /home/gj020900/www_nekonomagic/admin/admin-nove-anime.php on line 107
  </code></pre>
  
  <p>Shorted form:</p>
  
  <pre><code>&lt;form enctype="multipart/form-data" action="../admin/admin-nove-anime.php" method="post" role="form"&gt;
      &lt;div class="form-group col-md-6"&gt;
          &lt;!-- MAX_FILE_SIZE must precede the file input field --&gt;
          &lt;input type="hidden" name="MAX_FILE_SIZE" value="3145728" /&gt;
          &lt;label for="obrazok" class=""&gt; Obrázok anime (Max. 3MB):&lt;/label&gt;
          &lt;input type="file" name="obrazok" id="obrazok" class="form-control" required&gt;
      &lt;/div&gt;
      &lt;div class="form-group col-md-12"&gt;
          &lt;input type="submit" class="btn btn-success" name="pridaj_anime_submit" value="Pridať anime" style="width: 100%;"&gt;
      &lt;/div&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>PHP part:</p>
  
  <pre><code>if (isset($_POST['pridaj_anime_submit'])) {
      // skontroluje sa ci sa subor ulozil ak ano pokracuje ak nie napise chybu
      $uploaddir = '/www_nekonomagic/res/img/anime/uploads/';
      $uploadfile = $uploaddir . basename($_FILES['obrazok']['name']);
      if (move_uploaded_file($_FILES['obrazok']['tmp_name'], $uploadfile)) {
          // prva cast formy
          $nazov = mysqli_real_escape_string($connect_to_db, $_POST['nazov']);
          $rok = mysqli_real_escape_string($connect_to_db, $_POST['rok']);
          $pocet = mysqli_real_escape_string($connect_to_db, $_POST['pocet']);
          $preklad = mysqli_real_escape_string($connect_to_db, $_POST['preklad']);
          $stav = mysqli_real_escape_string($connect_to_db, $_POST['stav']);
  
          $sql_vloz_anime = "INSERT INTO anime (a_name, a_year, a_translated_min, a_translated_max, a_rate_min, a_rate_max, a_edit, a_condition)
                                    VALUES ('$nazov', '$rok', '0', '$pocet', '8', '10', '$preklad', '$stav')";
          mysqli_query($connect_to_db, $sql_vloz_anime);
          $sql_ziskaj_a_id_pridaneho_anime = "SELECT * FROM anime WHERE a_name = '$nazov'";
          $run_sql_ziskaj_a_id_pridaneho_anime = mysqli_query($connect_to_db, $sql_ziskaj_a_id_pridaneho_anime);
          $a_id_ziskane = "";
  
          while ($db_data = mysqli_fetch_assoc($run_sql_ziskaj_a_id_pridaneho_anime)) {
              $a_id_ziskane = $db_data['a_id'];
          }
  
          // druha cast formy
          $obrazok = mysqli_real_escape_string($connect_to_db, $uploaddir.$_FILES['obrazok']['name']);
          $zaciatok = mysqli_real_escape_string($connect_to_db, $_POST['zaciatok']);
          $koniec = mysqli_real_escape_string($connect_to_db, $_POST['koniec']);
          $cas = mysqli_real_escape_string($connect_to_db, $_POST['cas']);
          $akihabara = mysqli_real_escape_string($connect_to_db, $_POST['akihabara']);
  
          $sql_vloz_anime_info = "INSERT INTO anime_info (a_id, a_img, a_start, a_stop, a_time_ep, a_akihabara)
                                              VALUES ('$a_id_ziskane', '$obrazok', '$zaciatok', '$koniec', '$cas', '$akihabara')";
          mysqli_query($connect_to_db, $sql_vloz_anime_info);
      } 
      else {
          echo "
              &lt;div class=\"alert alert-success alert-info\" style=\"margin: 10px 0\"&gt;
                  &lt;a href=\"#\" class=\"close\" data-dismiss=\"alert\" aria-label=\"close\"&gt;&amp;times;&lt;/a&gt;
                  &lt;strong&gt;POZOR!&lt;/strong&gt; Súbor sa nepodarilo nahrať.
              &lt;/div&gt;
          ";
      }
  }
  </code></pre>