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
- How to stop showing admin notice after close button has been clicked
- What plugin can I use to create a list / slideshow of featured images?
- How to save the values of checkbox to the register setting?
- How to get Login Error messages on a custom template
- Way to force media uploader use custom image size
- Enqueue style inside shortcode but its loaded at the bottom of page (before footer scripts)
- Claim Listing functionality – how to send email to users when their claim has been approved or denied
- Where is the source code that makes the “all” array grabs filters in the $wp_filter?
- Options page not displayed under Settings menu
- How to include and use custom class files in plugin?
- Changing labels of status filters for post grid
- Where to call add_shortcode function in WordPress Plugin Boilerplate?
- Media upload not working on theme option in WordPress 3.8.1
- Own plugin corrups plugin-activation
- wordpress plugin is not activating from widget
- finding whether request is for post, and post id
- How to fetch products with the price in a page on woocommerce using a form or live search with php
- Owl Carousel2 image not displaying full width when using Stretch row and content, Stretch row and content(no padding) in wordpress
- Force language in translate function
- wp_footer hook only working on homepage not in other pages
- Setup wp_schedule_event within a custom plugin
- execute function after one completed
- How can I run a custom shortcode function on a live site and only run if the viewer is a specific machine?
- Can I use register_settings and unregister_setting once the settings page has loaded?
- Plugin function inside custom plugin
- How to Resize the Custom Post Images?
- Class or function wrapper for plugin code
- Extending a theme: build new features as plugin or core modules?
- Plugin generating unexpected output – on WP mysql dump import
- Remember the Meta Value With Radio Buttons
- How to embed a new string in url?
- help intercepting save_post through plugin
- best way to run a php script away from the template?
- Add hook after content without formatting
- User loggedin as Subscriber form not sending
- wc_get_template_part doesnt display the content [duplicate]
- admin_post hook not firing function inside class
- Thumbnail image doesn’t show up in Shortcode output
- how to auto random increment for post view
- how to split and upload a theme on wordpress?
- Fatal error: require_once(): Failed opening required
- How to properly enqueue jQuery knob on WordPress without conflict?
- How to save the option’s new values plus old value without overwrite old one
- Not displaying Woocommerce product page in lightbox
- Not able to upload Plugins/ Theme from Admin backend
- Can we validate data from jquery
- WordPress environment not loading properly
- Where to store media uploaded by the plugin?
- how can i get records from wp_postmeta table using particular meta_key in database?
- Getting error “The package could not be installed. PCLZIP_ERR_BAD_FORMAT ”
- wordpress plugin | short code issue
- Function not being called on form submit, only blank admin-post.php page
- how to get the url of a custom uploaded file
- A way to upload old html pages with all its assets via WordPress admin and to add a fixed menu on top of those (a la Wayback Machine)
- How do I set register_meta for a specific CPT?
- How to Enfroce Domain Licensing Limits? [closed]
- How can I save the selected page in the dropdown after anyone clicks on Save Changes?
- Update Content for a Custom Block Toolbar Button
- How can I save the selected page in the dropdown after anyone clicks on Save Changes?
- Wrong block appender button showing
- Uncaught Error: Cannot use object of type stdClass while showing the list using WP_List_Table
- How to give specific class name to category in wordpress with code snippets
- Submitting form to admin-post.php WordPress
- WordPress Throwing Deprecated Errors on its own Files
- plugin doesn’t retrieve data from database
- Display Any Field fromAdmin Panel in Frontend via Shortcode?
- Is Nonce Verification (CSRF) required for WordPress Custom Bulk User Actions?
- WordPress.Security.NonceVerification.Recommended
- BBPress Customization with Custom Plugin
- How can we extent core/group or cover block?
- Need to add custom cart item data
- I want to create a search option for CPT using plugin. The search options should search for categories and tags
- plugin development code standard not matching for SQL query
- Ajax response from Media Selection does not update ALL information more than once
- How do I apply different block supports to different parts of my custom block?
- Custom Gutenberg blocks not showing in WP editor