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.
There are some plugins that help you to rename the file uploaded. Please try this one https://wordpress.org/plugins/media-file-renamer/
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
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.
I saw this was recently added. Thank you very much for this feature and great support.
I tried this amd it works. But the file name displayed in the meta box isn't encoded properly.
In the folder the file name has spaces in it which we want. But when the attached file is shown in the Meta Box the encoding has %20 instead of spaces.