**** html
<form enctype="multipart/form-data" method="post" action="">
<input type="file" name="file" id="file">
<input type="submit" value="upload" name="submit">
</form>
**** file uploads.php
$allowedExts = array("wmv","avi","mpeg","mpg","mp4");
$extension = end(explode(".", $_FILES["file"]["name"]));
if ((($_FILES["file"]["type"] == "video/avi")|| ($_FILES["file"]["type"] == "video/mpeg")
|| ($_FILES["file"]["type"] == "video/mp4")
|| ($_FILES["file"]["type"] == "video/wmv")
|| ($_FILES["file"]["type"] == "video/mpg"))
&& ($_FILES["file"]["size"] < 2000000000000000)
&& in_array($extension, $allowedExts)){
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("upload/" . $_FILES["file"]["name"])){
echo $_FILES["file"]["name"] . " already exists. ";
}else{
move_uploaded_file($_FILES["file"]["tmp_name"],
uploads/đường_dẫn/".$_FILES["file"]["name"]);
//echo "Stored in: " . "upload/" . $_FILES["file"]["name"];
}
}
}else{
echo "Invalid file";
}
**** Views Videos
<video width="800" heigh="400" controls>
<source src="aicap.mp4" type="video/mp4">
</video>
**** Nâng cấp size upload
linkweb: http://ninhdon.com/tang-gioi-han-kich-thuoc-upload-file-trong-wordpress/#.VvUEtnqQXIV
Hi bạn, ngoài 2 cách trên thì cách thứ 3 cũng tương tự như 2 cách con lại. Cũng phải thêm code vào 1 file, nếu host của bạn hỗ trợ Rewrite URL thì thêm ngày đoạn code sau vào file .htacess ngay nhé:
php_value upload_max_filesize 64M php_value post_max_size 64M php_value max_execution_time 300 php_value max_input_time 300
linkweb: https://www.daniweb.com/programming/web-development/threads/322219/uploading-video-files-in-php
