how to validate video file type?-VBForums
Results 1 to 5 of 5

Thread: how to validate video file type?

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Jul 2005
    Posts
    840

    Resolved 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.

  2. #2
    Fanatic Member
    Join Date
    Oct 2004
    Posts
    751

    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
    }
    ?>
    My Projects: [ Instant Messagener Client/Server ] [ VBPictochat ]

    My Sites:
    [ Datanethost ]
    [ Helpdesk ]

    Remember if my post was helpful then Rate This Post.

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    Jul 2005
    Posts
    840

    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";

  4. #4
    Fanatic Member
    Join Date
    Oct 2004
    Posts
    751

    Re: how to validate video file type?

    Upload your script (if its not to big).
    My Projects: [ Instant Messagener Client/Server ] [ VBPictochat ]

    My Sites:
    [ Datanethost ]
    [ Helpdesk ]

    Remember if my post was helpful then Rate This Post.

  5. #5

    Thread Starter
    Fanatic Member
    Join Date
    Jul 2005
    Posts
    840

    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
  •  



Featured


Click Here to Expand Forum to Full Width

Survey posted by VBForums.