-
Nov 26th, 2005, 09:17 AM
#1
Thread Starter
Fanatic Member
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!";
}
}
?>
Last edited by kenny_oh; Dec 2nd, 2005 at 07:27 PM.
-
Nov 26th, 2005, 12:50 PM
#2
Fanatic Member
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
}
?>
-
Nov 27th, 2005, 10:00 AM
#3
Thread Starter
Fanatic Member
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";
-
Nov 27th, 2005, 11:44 PM
#4
Fanatic Member
Re: how to validate video file type?
Upload your script (if its not to big).
-
Nov 28th, 2005, 03:13 AM
#5
Thread Starter
Fanatic Member
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!";
}
}
?>
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|