Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • How to validate files in Wordpress

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 246
    Comment on it

    Hello Friends,

    If you want to check the file existence in Word Press or you want to check file type is right or not. Wordpress provide an inbuilt functionality to check this with validate_file(). Please look at below examples for the same:

    // Define allowed file type
    $extension = array('jpg', 'jpeg', 'gif', 'png');
    
    // Path for the file
    $path = 'uploads/2016/01/abcxyz.jpg';
    
    // Check file vaildation
    $flag = validate_file($path, $extension);
    
    // Return values meaning
    $flag == 0 // mean file exist
    $flag == 1 // mean file invalid
    $flag == 2 // mean file invalid
    $flag == 3 // mean file extension not allowed
    
    
    

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: