Custom Fields
Support General Custom upload file name

  • Creator
  • #27579
    Resolved sherwin_flight


    I'm using a "File" field to upload files to a custom folder. I'm wondering if there's any way to change the name of the file that's uploaded?

    Right now I have a separate metabox for file uploads, that I created myself. Everything else has been created using the Metabox plugin. If I can figure out how to rename the uploaded files I could get rid of my custom metabox and just use th plugin.

Viewing 5 replies - 1 through 5 (of 5 total)
  • Author
  • #27601
    Long Nguyen


    There are some plugins that help you to rename the file uploaded. Please try this one


    I have some custom code I use for that right now, just wasn't sure how it would work with your plugin.

    The upload script we're using now has a callback for a custom upload folder, which your plugin also has, and a callback for a custom file name, which the Meta Box plugin doesn't have. We upload several types of files, and they're named differently depending on the document type.

    $unit_inspection_documentation_upload_overrides = array( 'test_form' => false, 'unique_filename_callback' => 'unit_inspection_documentation_filename' ); 
    $unit_inspection_documentation_uploaded_file = wp_handle_upload($_FILES['unit_inspection_documentation_attachment'], $unit_inspection_documentation_upload_overrides);

    So in our current code it calls a "unique_filename_callback" function to get the name of the file before passing it to wp_handle_upload. That function names the file based on values from the database. That all works as expected.

    However, I've been migrating our custom post metaboxes over to your plugin, and these uploads are the only part I can't figure out.

    It's not a huge problem, because if I can't figure it out I'll just use a second custom metabox with our own code for the file uploads, and use Meta Box for the rest. Was just hoping to combine them into one tabbed Meta Box.

    Right now I'm not sure how to integrate a custom filename function

    Long Nguyen


    Thank you for your feedback.

    I will inform the development team to support this option in future updates.


    Thanks! That's the only option that's missing from using Metabox for all of my custom metaboxes.

    Anh Tran

    Hi, it's just added to Meta Box and will be available in the next version.

Viewing 5 replies - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.