I want to upload files, which formats are mp4,webm,ogg
:) But when i am clicking upload button, he is uploading every type file types :) And saving as the file formats like a ".file" and calling "Sucessfully uploaded"
.. How to upload only mp4, web or ogg formats.. :) Here are my codes:
<main>
<form action="" method="post" enctype="multipart/form-data">
<input type="file" name="file"></input>
<input type="submit" value="Upload"></input>
</form>
<?php
$maxsize = 800000000;
$fileformat = substr(@$_FILES["file"]["name"],4,-4);
$filename = rand(0,99999999).$fileformat;
$filepath = "uploaded/".$filename;
if (@$_FILES["file"]["size"]>$maxsize) {
echo "maximum upload size is 800MB";
} else {
$d = @$_FILES["file"]["type"];
if ($d=="video/mp4" || $d=="video/webm" || $d="video/ogg"){
if (is_uploaded_file(@$_FILES["file"]["tmp_name"])) {
$move = move_uploaded_file($_FILES["file"]["tmp_name"],$filepath);
if ($move) {echo "succesfully uploaded";}
else {echo "upload error";}
}
} else {echo "Supported video formats are mp4, webm and ogg";}
}
?>
</main>
..dont have any sytax problems, only error is "Undefined index "file"
this should be normal error becouse i didnt choised file...