• Resolved zookri

    (@zookri)


    Hi,

    One of my pods has a pdf upload. I’d like the uploads from this pod to be stored in a custom directory outside of the uploads directory. After much searching, I understand that it is possible using plupload and hooking into the pods_upload_handle, but I don’t know where to begin. Does anyone have a coded example as a base for me to understand and adapt for my own scenario?

    Thanks everyone.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Contributor Scott Kingsley Clark

    (@sc0ttkclark)

    Hey sorry for the delay here — but we do not have a way to customize the directory used for uploads for Pods file fields. The best way to handle this would be to hook into after the Pod file field saves and move it from there.

    There’s a hook you can use: https://pods.io/docs/code/action-reference/pods_api_post_save_pod_item_podname/

    I can’t put together the custom code you’d need for this, but I can point you towards this:

    
    if ( ! empty( $pieces['fields']['my_single_file_upload_field']['value'] ) ) {
        $attachment_id = $pieces['fields']['my_single_file_upload_field']['value'];
    
        // Use the attachment ID to get the attachment data.
    
        // Check if the attachment location is already moved.
    
        // If the attachment needs to be moved, move it.
    
        // Update the attachment location meta with WordPress so it knows.
    }
    
    Thread Starter zookri

    (@zookri)

    Thanks Scott, that’s very helpful. Sadly too late for my current project but at least I’ve got a route now should I need to do this again…

    Have a great New Year,

    Will

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Custom Upload Directory for Pod’ is closed to new replies.