0

I have the following code but I would like to edit it so that it asks a user for a title and description, then they upload the file and finally once they submit it, it appears on the page as a thumbnail.

I am not asking for someone to do this for me, just to guide me in the right direction.

The code:

<?
$allowedExts = array("jpg", "jpeg", "gif", "png", "mp3", "mp4", "wma");
$allowType = array("video/mp4","audio/mp3","audio/wma","image/png","image/gif","image/jpeg");
$maxSize = 20000000000000;
$extension = pathinfo($_FILES['file']['name'], PATHINFO_EXTENSION);
$pathToUpload = 'upload/';

if (
    in_array($_FILES["file"]["type"], $allowType) &&
    in_array($extension, $allowedExts) &&
    $_FILES["file"]["size"] <= $maxSize
) {
    if ($_FILES["file"]["error"] > 0) {
        echo "Return Code: " . $_FILES["file"]["error"] . "<br />";
    } else {
        echo "Upload: " . $_FILES["file"]["name"] . "<br />";
        echo "Type: " . $_FILES["file"]["type"] . "<br />";
        echo "Size: " . ($_FILES["file"]["size"] / 1024) . " Kb<br />";
        echo "Temp file: " . $_FILES["file"]["tmp_name"] . "<br />";

        if (file_exists($pathToUpload . $_FILES["file"]["name"])) {
            echo $_FILES["file"]["name"] . " already exists. ";
        } else {
            move_uploaded_file($_FILES["file"]["tmp_name"], $pathToUpload . $_FILES["file"]["name"]);
            echo "Stored in: " . "upload/" . $_FILES["file"]["name"];
        }
    }
} else {
    echo "Invalid file";
}
Sverri M. Olsen
  • 13,055
  • 3
  • 36
  • 52
  • possible duplicate of [How do I embed a mp4 movie into my html?](http://stackoverflow.com/questions/2299347/how-do-i-embed-a-mp4-movie-into-my-html) Not exactly a duplicate, but I guess you know how to output HTML from PHP. ;) – GolezTrol Mar 21 '14 at 21:43

1 Answers1

1

Generating a thumbnail: Generate preview image from Video file?

Displaying a video:

Community
  • 1
  • 1
Tarka
  • 4,041
  • 2
  • 22
  • 33