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

  • 1
    the function "wp_handle_upload" use the setting in "media" to store the file in folder split by month. maybe you have a plugin that change this way of storing files. – Kaperto Dec 9 '19 at 12:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.