Reputation: 11
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";
}
Upvotes: 0
Views: 141
Reputation: 4043
Generating a thumbnail: Generate preview image from Video file?
Displaying a video:
Upvotes: 1