validate_file
doesn’t quite work the way you’re expecting it to – it checks if $file
is in the allowed files array, not just its extension/mime type.
You’re looking for wp_check_filetype
. However, all that ultimately does is check the extension (i.e. it doesn’t read the headers of the file/ascertain the mime type otherwise).
Unless you implement your own PHP library for mime checking, it’d be quicker & easier to perform a simple regex check on the filename:
return preg_match( '/\.(mpe?g4?|webm)$/', $file ); // Or similar
Related Posts:
- How to link post image to post link?
- Local theme changes upload on server but theme changes not showing
- WooCommerce – edit templates
- Get property of non-object on theme activation
- change wordpress website logo url [duplicate]
- Custom page template not showing on page creation
- WordPress Custom font not found
- WordPress uploads do not show up and I see the white screen of death in some cases
- register_theme_directory() sees custom themes directory, but blank frontend
- Correct was to customise theme using get_theme_mod in scripts
- WordPress Twenty-Fourteen: How to Remove Home Page Header Image from Other Pages
- Custom theme vs theme customization?
- How to dowload and edit content of a website
- wp_editor some functionality not working on custom theme
- Update modified Shopify third-party theme [closed]
- Can’t upload images on new theme
- how can I re-utilize and class on a child theme
- hide/show a div in wordpress
- On wordpress, how do i require specific dimensions from user uploads only
- Providing updates to your WordPress theme
- One-Page WordPress Template
- Any way to permanently translate themes?
- New created Theme leads to malfunctioning Xampp Apache –> functions.php is cause
- Weird ‘theme update’ error [duplicate]
- WordPress Blog Page displaying nothing
- WordPress Theme Developments – Start from another theme
- Slider should be display in home template [closed]
- How one category can have different fields?
- How to create multiple pages in a client theme?
- How do child themes work?
- Modify comments_popup_link output
- Using Customizer value in an external PHP file inside a theme
- Fail to install theme on development copy of WordPress on Webmatrix
- How to prevent XSS attack in wordpress theme?
- Featured Image Module Randomly Disappears
- Best strategy for providing theme options using customizer
- Next post in category
- Primary Menu Showing All Pages With No Sub-Nav
- How to figure out which wordpress theme a site was using?
- Magnific Popup – Add Caption to Images
- Why do WordPress developers use so many opening and closing PHP tags when developing themes? [duplicate]
- Can you create a custom page with content in the center already defined?
- Safe way to echo wp_trim_words
- How to migrate the menu from the site on my own theme in WordPress?
- Import from HubSpot COS into WordPress 4?
- Incorrect search results in search.php – issue triggered by using `define(‘BodyID’, ‘search’); the_post();` in search.php
- Flexslider not working for my custom theme WordPress
- Theme Development : License help
- How can I demonstrate themes well?
- What’s the policy for building a theme that doesn’t support widgets/menus?
- “No Data Received” error in Chrome every time i try to update the theme functions file
- How Does One Create a Global Variable Repository
- Why the slideshow is not shown in my theme?
- Theme customizer live preview JS- Trying to bind to an html image url without luck
- RSS feed url showing page not found. How to solve it?
- Redirect to custom login page
- How to update my own theme?
- WordPress custom jquery not found
- WordPress two sidebar layout or theme
- Theme automatically inserting “more” tag on every post
- How get the 10 most viewed pages (not post)
- adding navigation to genesis themes
- How to close open divs in post loop
- Display Today’s date outside the loop?
- Standard Way To Do Custom Work Within A Page?
- Using wp_enqueue_script with social media buttons?
- Confused on loading page content
- Displaying Tags for the Page I’m On?
- Custom link color or stylesheets
- How to convert that page to a wordpress template? [closed]
- Toolbox theme using printif statement – help needed understanding code block
- Show post thumbnail only if it exists using timthumb
- Add Dynamic Sidebar to Exisiting WordPress Theme [closed]
- php file child theme directory not overriding parent theme php file [duplicate]
- How to make navigation a list without a plugin? [duplicate]
- Any Cool WordPress Theme Editor? [closed]
- How to Create a Multi Purpose Theme?
- Showcase your wordpress themes [closed]
- How can I install my custom-made theme on a wordpress.com blog? [closed]
- Turning WordPress Into full-featured website?
- How to use esc_attr__() function properly to translate a variable that contains string?
- Getting all months in one year WordPress Archive
- What is The Best Way to Make Parallax header effect for wordpress theme ?? pure CSS or using JavaScript? [closed]
- Why am I getting posts back when I shouldnt
- Purchased Theme to Custom Made Theme? [closed]
- How to make website with many template that active [closed]
- Custom Single Page Portfolio Theme [closed]
- Image Size wrong during upload
- How to remove proudly created by WordPress in theme?
- getting id of page
- Roll my own theme or customize an existing one [closed]
- How to create full header but keep content narrow
- Why do some sites show themes/”themename” as the only theme?
- Is there any open source WordPress Themes?
- How do I add new layout width options in WordPress editor?
- Correct way to make a custom block theme responsive
- .submenu class missing in output from wp_nav_menu
- How to make a multilingual wordpress site to be translated one-to-one without much effort and without using translate?
- Is there a way to have WordPress autodetect page templates in the page-templates directory and any sub-folders?
- What is the point of using the front-page.php template? [closed]