Image upload folder: one for each month and year just like wordpress

By: Francesco Brogi | Asked: 10/25/2023
ForumsCategory: How-toImage upload folder: one for each month and year just like wordpress
Francesco Brogi asked 9 months ago

When uploading a file via the Upload Field, I see that Formidable Forms creates a folder named with the ID of the form. I'd like to know if there is a way to create a folder for each month and year just like wordpress does. 

2 Answers
Rob LeVineRob LeVine answered 9 months ago
You can use frm_upload_folder
Francesco Brogi answered 9 months ago
Thank you! But what I meant was to automatically generate the new folders as well and then dynamically change the path.
Rob LeVineRob LeVine replied 9 months ago

It depends on what exactly you mean. You can definitely use that hook to create new folders by issuing simple PHP commands (e.g., https://www.w3schools.com/php/func_filesystem_mkdir.asp) and then that becomes the folder it's saving to. Let me know why it doesn't suffice and I'll try to think of another solution.

Francesco Brogi replied 9 months ago

Thank you Rob! I wonder if this is the right solution..I'll give you a deeper explanation of what I am dealing with.
I've got an upload field and the images are then sent to PDFMonkey to build PDFs. This is done via Zapier. All the images are uploaded into one folder.
It has worked happily and fine so far, but i started receiving a timeout error from PDFMonkey.
I spoke with the developers and they are saying that when they try to download any image they experience a heavy content download time. They say that depends on the hosting and the OS capabilities.
But I tried to change the uploading folder and I am still getting the time-out error.

I also cleared some of the files and it worked fine for a little and then it stopped again. I believe this happened because some more files got uploaded.
The error happened when changing the upload folder of the images. The previous folder and this new one are both subfolders of a parent folder called "Upload". I don't know if that is an issue with the number of files in the main folder and/or the size of the files. Some files can even be 230mb.

Rob LeVineRob LeVine replied 9 months ago

Well, I don't know enough in general or specific to your project to give a meaningful answer, so I'll just throw some ideas out there:
1. Make a separate directory for each user/entry so that there won't be as many files in each directory. It's possible the issue is that instead of sending some files, it's sending all each time.
2. Revisit using Zapier and PDF Monkey and either find a way to send just the URLs of the files to the service instead of the actual files or figure out another way to do what you're doing. Honestly, it seems odd to me that you're sending a bunch of files to a service so that it can make a PDF file.

Making the Best WordPress Plugin even better - Together

Take on bigger projects with confidence knowing you have access to an entire community of Formidable Experts and Professionals who have your back when the going gets tough. You got this!
Join the community
crossarrow-right