php code for video upload

Solutions on MaxInterview for php code for video upload by the best coders in the world

showing results for - "php code for video upload"
Emmanuel
28 Jan 2016
1<?php
2
3$allowedExts = array("jpg", "jpeg", "gif", "png", "mp3", "mp4", "wma");
4$extension = pathinfo($_FILES['file']['name'], PATHINFO_EXTENSION);
5
6if ((($_FILES["file"]["type"] == "video/mp4")
7|| ($_FILES["file"]["type"] == "audio/mp3")
8|| ($_FILES["file"]["type"] == "audio/wma")
9|| ($_FILES["file"]["type"] == "image/pjpeg")
10|| ($_FILES["file"]["type"] == "image/gif")
11|| ($_FILES["file"]["type"] == "image/jpeg"))
12
13&& ($_FILES["file"]["size"] < 20000)
14&& in_array($extension, $allowedExts))
15
16  {
17  if ($_FILES["file"]["error"] > 0)
18    {
19    echo "Return Code: " . $_FILES["file"]["error"] . "<br />";
20    }
21  else
22    {
23    echo "Upload: " . $_FILES["file"]["name"] . "<br />";
24    echo "Type: " . $_FILES["file"]["type"] . "<br />";
25    echo "Size: " . ($_FILES["file"]["size"] / 1024) . " Kb<br />";
26    echo "Temp file: " . $_FILES["file"]["tmp_name"] . "<br />";
27
28    if (file_exists("upload/" . $_FILES["file"]["name"]))
29      {
30      echo $_FILES["file"]["name"] . " already exists. ";
31      }
32    else
33      {
34      move_uploaded_file($_FILES["file"]["tmp_name"],
35      "upload/" . $_FILES["file"]["name"]);
36      echo "Stored in: " . "upload/" . $_FILES["file"]["name"];
37      }
38    }
39  }
40else
41  {
42  echo "Invalid file";
43  }
44?>
45
Gabriela
10 Feb 2017
1<form method="post" enctype="multipart/form-data">
2    <div><?php echo $message; ?></div>
3    <?php echo $max_file_size_tag; ?>
4    <input type="file" accept="video/*" ID="fileSelect" runat="server" size="20" name="filename" action="/vids/file-upload.php">
5    <select name="course">
6        <option value="select" selected>Select</option>
7        <option value="java">Java</option>
8        <option value="python">Python</option>
9        <option value="vb">Visual Basic</option>
10        <option value="c">C/C++</option>
11        <option value="ruby">Ruby</option>
12    </select>
13    <input type="submit" value="Upload" name="submit">
14</form>
15