how to validate video file type?
here is my php file for upload the video file...........how to write the validation of video file type? like if the file type is img, or not the .wmv, .rmvb.............as well as how to validate the file size??
Code:
<?php
if (!is_uploaded_file($_FILES['uploadfile']['tmp_name'])){
echo "you did not upload a file";
unlink($_FILES['uploadfile']['tmp_name']);
} else {
$target_path = "VideoUploadFolder/";
$target_path = $target_path.basename($_FILES['uploadfile']['name']);
if (move_uploaded_file($_FILES['uploadfile']['tmp_name'], $target_path)){
echo "the file ".basename($_FILES['uploadfile']['name']). " has been uploaded";
} else{
echo "there was an error uploading the file, please tryagain!";
}
}
?>
Re: how to validate video file type?
Well img isn't a movie its a picture (I googled it). (Also check out your other thread that I answered http://www.vbforums.com/showthread.php?t=370006 )
And $_FILES['uploadfile']['size'] returns the filesize.
So...
<?
if ($_FILES['uploadfile']['size'] > 1024){ //1mb
echo "file to big";
} else {
...upload file
}
?>
Re: how to validate video file type?
i have try the solution for validate file szie u give.....but it alway run the first if statement message
Code:
echo "you did not upload a file";
Re: how to validate video file type?
Upload your script (if its not to big).
Re: how to validate video file type?
i hv do two example...first one is same as the first #1 thread
Code:
<?php
if (!is_uploaded_file($_FILES['uploadfile']['tmp_name'])){
echo "you did not upload a file";
unlink($_FILES['uploadfile']['tmp_name']);
} else {
if ($_FILES['uploadfile']['size'] > 10240 ){
echo "The Uploaded file is too large";
unlink($_FILES['uploadfile']['tmp_name']);
} else{
$target_path = "VideoUploadFolder/";
$target_path = $target_path.basename($_FILES['uploadfile']['name']);
if (move_uploaded_file($_FILES['uploadfile']['tmp_name'], $target_path)){
echo "the file ".basename($_FILES['uploadfile']['name']). " has been uploaded";
} else{
echo "there was an error uploading the file, please tryagain!";
}
}
}
?>
Example 2:
Code:
<?php
$target_path = "VideoUploadFolder/";
$target_path = $target_path.basename($_FILES['uploadfile']['name']);
if ($_FILES['uploadfile']['size'] > 10240){
echo " file too big!!";
} else {
if (move_uploaded_file($_FILES['uploadfile']['tmp_name'], $target_path)){
echo "the file ".basename($_FILES['uploadfile']['name']). " has been uploaded";
} else{
echo "there was an error uploading the file, please tryagain!";
}
}
?>