I have been facing this issue that all the new media files are getting uploaded to single folder which was auto-generated during initial site development. Now since all new images are getting uploaded to single folder its very difficult to maintain.
Settings to organize media are enabled but that works only if media is uploaded from WP backend and i have written custom code for media upload as shown below:
require_once( ABSPATH . 'wp-admin/includes/image.php' ); require_once( ABSPATH . 'wp-admin/includes/file.php' ); require_once( ABSPATH . 'wp-admin/includes/media.php' ); $attachment_id = media_handle_upload( 'img', $_POST["add-to-cart"]);
So basically there is woocommerce cart where i have added custom media field from which user can upload media and storing the same using above code.
Any help much appreciated, Thanks