title: how to upload a video file into database in php
body: <p>i want to upload video from my computer to my website. already i add videos from other sites using links of video and using my own custom thumbnail for that video if i want.
  but now i want to upload video from my computer to database. and then display the video on my site. but i have no idea how to do it. </p>
  
  <p>i'm using this code for uploading video from my computer and also using this code from uploading video link from another site. but its not working for uploading video from my computer.</p>
  
  <p>please anyone can help me with example. i really appreciated your struggle. thanks </p>
  
  <pre><code>if (isset($_POST['video'])) {
      $video_url = $_POST['video_url'];
      $thumbnail_code = end(explode('/', $video_url));
      if ($_FILES["file"]["name"] != '') {
          $allowedExts = array("gif", "jpeg", "jpg", "png", "mp3", "mp4", "wma");
          $temp = explode(".", $_FILES["file"]["name"]);
          $extension = end($temp);
          if ((($_FILES["file"]["type"] == "image/gif")
                  || ($_FILES["file"]["type"] == "video/mp4")
                  || ($_FILES["file"]["type"] == "audio/mp3")
                  || ($_FILES["file"]["type"] == "audio/wma")
                  || ($_FILES["file"]["type"] == "image/jpeg")
                  || ($_FILES["file"]["type"] == "image/jpg")
                  || ($_FILES["file"]["type"] == "image/pjpeg")
                  || ($_FILES["file"]["type"] == "image/x-png")
                  || ($_FILES["file"]["type"] == "image/png"))
              &amp;&amp; in_array(strtolower($extension), $allowedExts)
          ) {
              if ($_FILES["file"]["error"] &gt; 0) {
                  echo "Return Code: " . $_FILES["file"]["error"] . "&lt;br&gt;";
              } else {
                  if (move_uploaded_file($_FILES["file"]["tmp_name"],
                      "../img/" . $_FILES["file"]["name"])) {
                      $imagenames = "../img/" . $_FILES["file"]["name"];
                  }
              }
          } else {
              echo "Invalid file";
          }
          $sql = "INSERT INTO abc (video_url,thumbnail_code,images)
                  VALUES('$video_url','$thumbnail_code','$imagenames')";
      } else {
          $sql = "INSERT INTO abc (video_url,thumbnail_code)
                  VALUES('$video_url','$thumbnail_code')";
      }
      $query = $conn-&gt;query($sql) or die ('no table found');
      if ($query) {
          $msg = "Video Added Successfully";
          header("location:video.php?msg=$msg");
      }
  }
  </code></pre>