Form File Uploads custom filename - Modification #15172
AntDsl
announced in
Developers Community
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hello,
When a user uploads a file through Elementor forms, the file is renamed automatically for security reasons and then it is uploaded on the server.
Because we are using the File Uploads field to collect CV's we get hundreds of files every week. We just download the files through FTP and we don't use "Collect Submissions" for this form since the files are so many.
A useful option would be, to be able to select a field to be added into the filename, for example, in our case, the "job position" text field. That way categorizing the files would be much easier. Of course the filename should be sanitized for security reasons.
For now, in order to make this work, I have modified the file wp-content/plugins/elementor-pro/modules/forms/fields/upload.php
adding the following lines in to the process_field function:
and modifying the line (~422) in process_field function from:
$filename = uniqid() . '.' . $file_extension;
to:
$filename = $position . '_' . uniqid() . '.' . $file_extension;
The text field is sanitized, by the "wp_unique_filename" function that is called afterwards.
keep in mind that this is only temporary, any update will restore the original file.
If you do make that modification don't forget to add the title of the text field you want to include.
Any suggestions for better implementation of this would be appreciated!
Beta Was this translation helpful? Give feedback.
All reactions