This should work – using wp_upload_dir
to get the path, then checking to see if it exists – and creating it if it doesn’t.
$upload_dir = wp_upload_dir();
if (!is_dir($upload_dir['path'])) { // directory doesn't exist
mkdir($structure, 0744, true); // the mode to use here may vary based on your hosting environment
}
Related Posts:
- how does wp.media javascript library work?
- How can I add a custom meta value on file upload?
- Deleting images through upload folder, but not deleting from media library
- Admin page: form with enctype=”multipart/form-data” does not transfer its data
- Upload file inside plugins options page
- Adding Attachment Display Settings in custom media frame
- How to find the origin of a file upload from within wp_handle_upload?
- wp.media javascript issue with on select
- Plugin Not Working After Being Uploaded To WordPress Plugin Repository
- Redirect to another page using contact form 7? [closed]
- Is it possible for a plugin to force reading and writing of uploaded images to a database instead of to a filesystem?
- adding a button to the media uploader
- custom uploader in the admin area
- Issue with wp_handle_upload
- How To Create A File Archive in WordPress?
- How to upload large media file in chunks, without any plugin?
- How to copy the all WordPress media items to another custom plugin folder?
- Access remote SFTP server via WordPress login?
- what functions to use to resize images and create DB metadata for them after/during upload?
- 500 Internal server error wp_handle_upload_prefilter
- Uploading images to custom table
- Media Upload to custom database and Custom Directory
- Upload Image to desired directory through plugin
- wp_handle_upload – specified file failed upload test
- Custom uploader – Upload files and save link into database
- media_sideload_image only works on localhost and without return id or src
- How to save post change url youtube link?
- Best approach to fetch data from wp options to js file or php file
- Correct way to perform non-cacheable DB query
- Allow users of my plugin to define their own shortcode rather than use mine?
- Is it possible to create Custom Post plug-in?
- uninstall.php file in Plugin to clean DB
- How organize uploaded media in WP?
- Archive – same title for the first two posts
- Creating a plugin to sanitize comment and the url field before display only
- Edit Yoast SEO breadcrumbs output [closed]
- Creating plugin using simple_html_dom parser?
- Object Oriented Plugin not working
- Does WP identify plugin by plugin name or plugin_basename?
- switched from query_posts to WP_query, not working now?
- Making a plugin only available on the front-end for the logged in super admin
- Create entire wordpress as a github repositery?
- Help With MySQL to WPDB Query Conversion
- When to load auto-login code?
- AJAX search posts and pages
- Plugin or method to delete uploads not in media library?
- How would I go about creating a user ranked post popularity page?
- CSV file generation failing
- Updating the Drag-To-Share eXtended share URLs?
- finding whether request is for post, and post id
- Building plugin with changeable custom post type values…advice needed
- How to get all of the activate_plugin action parameters?
- __callStatic method handler passed to add_action causes bug in PHP
- Enqueue WordPress plugin scripts below all other JS
- Display update notification messages like ‘What’s New’
- How to add Internationalization in WordPress using Javascript/React?
- CRUD and Frontend show from a custom table without shortcode
- How to get specific setting by settings_fields()?
- Save / Show multi line text in metabox
- Creating mySQL procedure with $wpdb
- how to disable blockrenderAppender inside all Innerblocks?
- why doesn’t this update part of this plugin work? it take me to nothing here page
- Redirection of users away from wp-admin (but not administrators)
- WordPress Gutenberg react make import of __experimentalUseInnerBlocksProps which is no more experimetal
- Using a custom plugin to capture input data via Ajax and PHP
- Python with wordpress plugin
- Display post lists in 2nd paragraph
- Map Custom Registration Fields to WordPress User Roles
- Not able to add option in Sub-Menu under page
- How to stop activating a plugin and show admin notice when dependent plugins minimum version is not met
- Using a post-signup hook to get user details
- How to change File URL in file uploaded to s3 compatible storage with self written plugin [closed]
- How to apply a patch via plugin?
- Fixing WordPress’s Bug (failed to send buffer of zlib output compression) results in “White Screen of Death”
- Restrict media upload size by format
- Disable woocommerce cookies and delete cart data automatically
- Ajax contact form widget plugin data not insert in database
- link bbpress forum discussion to blogposts
- Install Plugin via Code
- code is working properly in Core PHP but writing coding in WordPress
- Combine scripts from all extensions of the plugin when an extension is activated
- Creating a custom post type, adding custom meta fields, preventing all future editability of posts of this type
- Prevent duplicate records in plugin table
- Send Custom welcome email to specific user group
- woocommerce payment gateway callback not firing [closed]
- How to modify WCMP Rest API response?
- Fetch Children of Grouped Products Inside WooCommerce Product Loop
- White page by using filter template_include
- How to fetch products with the price in a page on woocommerce using a form or live search with php
- Making a Template for a CPT created by a plugin
- Woocommerce dependent plugin
- WordPress.org Plugin Directory doesn’t recognise screenshots [closed]
- External CSS in WordPress Plugin [closed]
- How to check current user before all actions and filters?
- Owl Carousel2 image not displaying full width when using Stretch row and content, Stretch row and content(no padding) in wordpress
- User Session and Stored Cookies not get removed
- New databes tables with – WooCommerce – for developers [closed]
- How can I prevent my plugin go development trunk [closed]
- Plugin-generated pages use Not Found or Pages Archive templates?
- How can I make 2 plugins that include different versions of a framework to both use the latest version?