Custom Fields
Re-Envisioned
Support General Change Destination Of Custom File Upload Field Type

This topic contains 12 replies, has 4 voices, and was last updated by  Anh Tran 4 months, 3 weeks ago.

  • Creator
    Topic
  • #11274
    Resolved
    Lucjan Zaborowski
    Participant

    Hello Folks

    I have a bit different requirement. We would like to upload files on specific destination like in my root (/downloads) . Currently its uploading on my uploads directory. I want to upload in different folder.

    Full Scenario:

    We are uploading two files(PDF) for all posts. 1 for public download and 1 for gated like people will fill the form and would be able to download.

    so While adding a post we have two file type options for upload the files. now we want to upload the file on ROOT_PATH/downloads and ROOT_PATH/downloads/gated

    Please help me with this. Thanks in advance.

Viewing 2 replies - 11 through 12 (of 12 total)
  • Author
    Replies
  • #13453

    LFFprop
    Participant

    Hi Anh,

    Great feature!

    I would like to use it in a multisite installation. Is there a way to upload it to an upload folder within that subsite, without hardcoding the sitenumber in the path?

    For multisite installation the regualar path is ../wp-contents/uploads/sites/<sitenumber>/<foldername>.
    Is it possible to specify as path ../wp-contents/uploads/<foldername>, and that automatically the /sites/ and sitenumber are added?

    It would make setting up a new subsite so much easier…

    #13476

    Anh Tran
    Keymaster

    Hi,

    To avoid the complexity, I avoided using predefined variables for things like site number in multisite network. But you can always do that with a little code, like this:

    function prefix_get_site_upload_dir() {
        return WP_CONTENT_DIR . '/uploads/sites/' . get_current_blog_id() . '/my_uploads/';
    }

    And in the field settings, set:

    'upload_dir' => prefix_get_site_upload_dir(),

Viewing 2 replies - 11 through 12 (of 12 total)

You must be logged in to reply to this topic.