Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Contributor Ismail

    (@elhardoum)

    Hello,

    Thank you. Yes that is possible with the following code to your child theme’s functions file:

    function afu_filter_upload_dir( $dir ) {
        return array(
            'path'   => ABSPATH . '/my_uploads_folder', // or $dir['basedir'] . folder
            'url'    => home_url() . '/my_uploads_folder', // or $dir['basedir'] . folder
            'subdir' => '/afu',
        ) + $dir;
    }
    
    function afu_do_filter_upload_dir() {
        if ( ! empty( $_REQUEST['action'] ) ) {
            if ( 'ajax_file_upload' == $_REQUEST['action'] ) {
                add_filter( 'upload_dir', 'afu_filter_upload_dir' );
            }
        }
    }
    add_action( 'init', 'afu_do_filter_upload_dir', 999 );

    Make sure to set the appropriate folder path and url, and the subdir (sub directory) if needed and please test it out.

    Let me know how it goes.

    Thank you!
    Samuel

    Thread Starter Clei

    (@juanki)

    Great!
    Thanks a lot!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Change upload folder’ is closed to new replies.