samedi 17 octobre 2020

Video won't play (but does upload)

I have created a website where it's possible to upload video, but the video won't play( once it's uploaded): I have tried everything, but still doesn't work:

Any suggestions?

I have attached the code under her (but I don't think the code is the problem): Do I have to add something in the file "mime"?

<!DOCTYPE html>
<html>
<body>

<form action="upload.php" method='post' enctype="multipart/form-data">
<input type="file" name="file"/><br><br>
    <input type="submit" value="Upload"/>
</form>
</form>


</body>
</html>

<?php 

$name= $_FILES['file']['name'];

$tmp_name= $_FILES['file']['tmp_name'];

$position= strpos($name, ".");

$fileextension= substr($name, $position + 1);

$fileextension= strtolower($fileextension);


if (isset($name)) {

$path= 'Hell';
if (empty($name))
{
echo "Please choose a file";
}
else if (!empty($name)){
if (($fileextension !== "mp4") && ($fileextension !== "ogg") && ($fileextension !== "webm"))
{
echo "The file extension must be .mp4, .ogg, or .webm in order to be uploaded";
}


else if (($fileextension == "mp4") || ($fileextension == "ogg") || ($fileextension == "webm"))
{
if (move_uploaded_file($tmp_name, $path.$name)) {
echo 'Uploaded!';
}
}
}
}
?>


<?php

if (($fileextension == "mp4") || ($fileextension == "mov") || ($fileextension == "webm"))
{
echo "<video width='1000' controls>
<source src='$path/$name' type='video/$fileextension'>
Your browser does not support the video tag.
</video>";

}

?>



Aucun commentaire:

Enregistrer un commentaire