The closest is the WP Filesystem API, but that’s mainly intended for compatibility purposes, e.g. to enable files to be written when the only access is via FTP and direct filesystem write access is unavailable.
Particularly: https://developer.wordpress.org/reference/classes/wp_filesystem_base/dirlist/
However, if you are not distributing this code and only using it for yourself or known environments, you can use standard PHP APIs.
Note that you will need to perform some recursion to achieve this task, and there are costs to doing this, especially if the filesystem specified for WordPress involves remote requests such as FTP/S3/etc
Related Posts:
- Correct Syntax for uploading files to custom directory in WordPress
- How to change upload directory in wp_handle_upload
- Uploading media with the REST API
- Decrease file size upload in Media
- Adding a custom image upload size and making it selected by default?
- Change the filename format of saved featured images
- Image Upload “exceeds the maximum upload size for this site”, but php.ini is correct
- How to register images uploaded via FTP in media library?
- Failed media upload: “The uploaded file was only partially uploaded.”
- Namespacing WordPress project according to FIG standards
- Create Image Uploader for Widget
- Using file_exists to check file in Uploads
- Rename image uploads replacing “width” and “height” in filename with “medium”, “large”, “small”
- Rename image uploads with width in filename
- Modify image while uploading
- Debugging upload problem: What part of WP does actual image-resizing?
- How to resize image on client-side before upload?
- Specified file failed upload test. wp_upload_handle
- Does wordpress allow me to add a php file to the root directory to execute custom scripts?
- How to upload imagick resource to media in wordpress
- Accessing a random image via ajax
- Make WordPress upload directory outside wordpress root with custom url
- Is it unsafe to put php in the /wp-content/uploads directory?
- Upload images and attachments from frontend form
- Image upload via FTP to wordpress media library
- WordPress media upload “HTTP error”
- Adding featured image via PHP
- How to enlarge the media file upload size in wordpress admin
- What’s the proper way to use wp_enqueue_script/style?
- Restrict WordPress File Type Uploads by User Type
- File upload, uploads only file name
- Modify Maximum upload file size text
- Adding a querystring to an image URL when clicking ‘insert into post’?
- Use WordPress’s Media Uploader/ Manager in non WordPress php application
- Upload a json file in php [closed]
- Custom image upload
- wp_handle_upload – The uploaded file could not be moved to wp-content/uploads/2012/09
- is it possible to force wordpress to always save thumbnails as ‘jpg’ not ‘png’
- Memory errors with media upload, WordPress can’t use more than 96M (while there’s 512 available!)
- Validate Uploaded Image using WordPress’ Built-in Functions?
- Change the actual (or viewable) WordPress directory structure
- Get most recent media upload
- Convert all images to PNG on file upload
- How to restrict wp generate attachment metadata() to certain intermediate image sizes
- Upload Image in a WordPress page using PHP
- WordPress (3.9.1) MultiSite Permissions. Is chown the answer?
- Accessing site’s root from themes folder
- Randomise upload filenames (or another solution to hide the original image URL from theft?)
- Using file_get_contents with Gravity Forms uploads folder to create images in the media library returning false
- how to retrieve uploaded url of zip files
- Custom location for attached images
- Using a `Template Parts` folder instead of an `Includes` folder in a Custom WordPress Theme
- Why is $_REQUEST an empty array in admin-ajax.php?
- How to Arrange PHP Files to Allow for Multiple Types of Pages?
- Correct folder permissions?
- PDF file randomly breaks upon upload
- Image upload via FormData API and AJAX is not working ($_FILES always empty)
- How to upload a file to a folder named after the user_id via plugin
- Need help with Google drive API [closed]
- Can’t upload image using media_sideload_image
- subdirectory index.php is not working
- Upload multiple images to a Woocomerce product
- What is the alternative to “ when it comes to calling Media (image) files in the ‘attachment.php’ file?
- Accessing an image folder inside public web directory
- Upload file could not be moved to wp-content/uploads
- WordPress file upload
- Upload images from one server to an other in wordpress
- Crop an image after upload on custom account page
- media_handle_upload fails with gravity form submitted image
- Restrict File Type Uploads by User on Wordress via functions.php
- How do I prevent a folder from reappearing in my home directory?
- wp_delete_attachment not working with multiple values
- Resource 404 error on multisite subdirectory install
- Renaming “Expand Details” within “Add Media”
- Save the outputted image into the Media Library, with a different filename and extension
- 403 (Forbidden) delete file image in themer folder
- File path for attachments outside of wp-content/uploads
- Is custom behaviour possible when asynchronously uploading?
- How to resize an image server-side before upload?
- WordPress will suddenly stop saving files uploaded by my code (ran in nopriv ajax)
- Permission functions within wordpress
- Name Input from widget displays Sidebar name instead of saved data
- Can’t upload files
- WP white screen of death after duping a site that works fine on same server
- File Upload with Server in safe_mode
- Edit Image/Image Details – Replace button missing
- Can I have a php site on subdirectory of WordPress?
- How to automatically convert images to WebP on WordPress?
- Generate and upload screenshot as featured image for user-submitted post
- Pull latest Youtube Video from json url and make new post
- WordPress directories not writable after PHP version upgrade
- Upload multiple files via ajax from an HTML file input
- get_post_meta returns on side but it doesn’t return on bottom of admin page
- “Unexpected response from server” error when trying to upload any .mp4 file over 100MB
- Changing upload directory temporarily
- How can we upload custom page files?
- Restricting Image Upload Sizes using ‘wp_handle_upload_prefilter’ – Stuck media progress bar when Featured Image?
- How to link the path of a folder situated in public.html for a random video player?
- How to save WordPress post and attachment images from front end using media library?
- Unable to upload media to WordPress