Disorganized file uploads can quickly become a nightmare. When managing hundreds of unnamed files from forms or projects, it’s impossible to find what you need efficiently. That’s why implementing custom folders and organization systems for uploads is critical.
In this article, you’ll learn how to create custom directories for file uploads in WordPress, while also providing instructions on how to rename uploaded files in WordPress. These two vital tasks go hand in hand, and our guide will walk you through the process step-by-step. Say hello to seamless file management in WordPress with Ninja Forms and File Uploads add-on!
Customize Uploaded File Names in WordPress
With our masterful file upload plugin, you can easily rename the uploaded files. Just click on the File Upload field on your form and locate Rename Uploaded File field.
Here, you can rename the uploaded files using merge tags and any special characters you like. The file will not retain the same name your users gave it when uploading it to your form. The Rename setting will override the original name of the uploaded file.
In our example below, with the help of merge tags, we rename the file using the first name, last name, and date including the day, month, and year. The original file name of the uploaded file was different.
To see the results of how the renamed field looked like, we embedded the uploaded file in an email confirmation message and sent it to ourselves for a preview.
As you can see the name of the uploaded file is NameSurname2023-07-11.png. This is because of the merge tags we used. Please note, you can only use these merge tags if there are existing form fields for them in your WordPress form.
Also, you can use any special characters between the merge tags under the Rename Uploaded File section. For example, you could enter {field:name}_{field:lastname_1689103983838}_{other:formatted_date} or you could enter {field:name} – {field:lastname_1689103983838} – {other:formatted_date}.
Renaming uploaded files using shortcodes
Another way to rename the uploaded files to your WordPress form is via “shortcodes” that can mix with the merge tags. Here is the list of shortcodes that are supported when you are renaming your uploaded files:
On the other hand, if you don’t want to rename the uploaded file and prefer to retain the same file name that the user gave it, leave the Rename Uploaded File field blank.
If users upload an image with the same file name, the file name will be modified by appending a sequentially numbered suffix — filename, filename – 1, filename – 2, etc.
Now that we explained how to rename uploaded files in your WordPress form, let’s finally look at how you can create dynamic directories for your file uploads. We will also show you an example of creating a custom directory in Dropbox if you prefer sending files to this external storage service.
How to create custom directories for file uploads in WordPress
Organizing your file uploads and saving them into separate folders for different forms is very convenient. If you want to create custom folders for your uploaded files, the process is very similar to renaming your uploaded files.
In the same Rename Uploaded File setting, you can create folders using the forward slashes (/) in order to create/save files to specific directories with the help of the merge tag icons or shortcodes.
In our example below, you can see we created a custom folder using forward slashes and the merge tag for the Last Name field.
Another way to create a custom directory is to navigate to your WordPress dashboard > Ninja Forms > File Uploads > Upload Settings > Custom Directory. Please note this is a setting for creating custom folders in WordPress not in the external storage services.
Create custom directories for external file upload in WordPress (Dropbox example)
Probably the most common reason to create dynamic folders for uploaded files is to send them into a designated user folder in your external storage service. In our example, we will demonstrate how you can create dynamic folders in Dropbox.
There are two things you want to make sure you do first before your file upload management quest begins:
- Connect Ninja Forms to your Dropbox account under External Settings.
- Toggle on Enable External Storage File Upload under Emails & Actions and enable Dropbox file upload once you connected to your Dropbox account.
Once you are done here, it’s finally time to create our custom directories for file uploads! Let’s say you are collecting job applications on your form and you want to create a folder in your Dropbox called Job Applications.
Head over to Ninja Forms > File Uploads > External Settings and enter /Job Applications/ to the File Path section as shown below.
This is how you create a custom directory for your files. You could also add another subdirectory into the File Path continuing like this: /Job Applications/Hiring Season 2023/.
Create a dynamic subfolder with the user’ First Name and Last Name in Dropbox
If you want to also create a dynamic subfolder with the first and last name of the user who submitted the file, you’ll need to do an additional step. Leave the File Path as is (/Job Applications/) and head over to your File Upload field in your form. Locate the section Rename File Upload field and enter the following:
As you can see, we entered a merge tag for the first name and last name, used a forward slash to make it a folder, and included the file upload.
Below is the result in Dropbox if you followed our instructions. You’ll notice Ninja Forms Uploads folder. This directory is automatically created when you connect your Dropbox account with Ninja Forms via the File Uploads add-on. It is a root directory and can’t be changed at this time.
That’s it! You’ve just learned how to import WordPress form attachments into custom directories in Dropbox. Want to learn more about external file upload?
Check the following blog posts: How to Upload Files to Google Drive from WordPress, Connect to Amazon S3 with WordPress File Upload Plugin, and How to Upload Files to Dropbox from WordPress.
File Uploads is the ultimate powerhouse plugin from Ninja Forms!
Ninja Forms’ File Uploads plugin makes it simple to set up targeted directories and keep your uploads neatly sorted, whether locally or in cloud storage. It’s time you take back control of your WordPress file organization.
Unlike our competitors, you can get our file upload plugin individually. You can also enjoy its benefits as part of any of our membership plans.
With a 14-day money-back guarantee, you have nothing to lose. Want to learn more about our powerhouse add-on? Discover what’s possible in our Complete Guide to Adding a File Upload Field to Your Form!
Yves Carrier says:
Hi, As I asked last year, I can only repeat my Change Request for File Upload. As Windows allows all french characters and some special characters in filenames, you should stop removing those characters and replacing them by english characters. This is a major problem for french users who must go back into their Dropbox or Google Drive folder and manually putting the french characters back into the final filename. This is very time consuming and frustrating. It’s a simple validation that you have to do in order to accept all characters allowed by Windows in filenames.