Posts: 11
Threads: 4
Joined: Feb 2010
Reputation:
0
Hi.
Is it possible to have file uploads be sorted per form submission? In other words: creating unique folders for each submission under the form's main folder.
For example: .../formtools/forms/{$FORMNAME}/files/{$SUBMISSIONDATE}_{$TITLE}
(By the way, is it possible to use reference variables outside of the e-mail function? I'm only using the reference variable format above to try and explain what would be a desirable solution.)
Would this be possible without the submission pre-parser or would one have to create a custom script to be used with the pre-parser?
Has anyone done something similar to this?
Posts: 2,456
Threads: 39
Joined: Dec 2008
Reputation:
6
Hey Craven,
Very interesting...! But unfortunately, not terribly easy.
Using the form name dynamically in the folder structure is the trickiest bit. The upload paths and URLs are specified for each form field; I don't see a way to circumvent that to look in a custom location... I think that that would take a modification to the core script, which could be tricky.
For the next bit: the custom filenames, I'm actually a little surprised the script doesn't do this out-the-box (I thought it did!). So instead you'd need to look into the Submission Pre-Parser module, like you noted.
Sorry - not terribly useful. This is actually a rather tricky problem.
- Ben
Posts: 11
Threads: 4
Joined: Feb 2010
Reputation:
0
Hi Ben.
Thanks for the reply.
We're currently troubleshooting for possible causes of this happening, as we at first thought it to be because of the duplicate file names, but seems to now not be the sole possible reason of the cause.
We set up a separate server and transferred the database and Form Tools files, but not any of the data. When submitting to that separate installation, it yet again randomly did not upload some of the files in no apparent order or sequence.
A possible cause could be that in the process of upgrading to Form Tools 2.0.2, importing the previous database and keeping the existing uploaded files, it might have influenced the way the processing is done? (Only guessing here. But probably not the reason.)
Another way we could possibly test the working of this is by setting up a clean installation of Form Tools, have a clean database and use a very basic form and do the exact same submission with the same files and see what the outcome is. (Will get back to you on this.)
We did notice that Form Tools renames the files disregarding of whether there are duplicates or not (such as in this case where there were no files in the uploading folder). Is this by design? It seems to strip the file name of spaces and numbers and prefix a number. Or does it do a check for existing filenames in the database and not in the uploading folder?
Sorry about the long post. Just a lot of questions and thinking surrounding the cause and what solution we'll have to find for this.
Thanks for your time.
Posts: 2,456
Threads: 39
Joined: Dec 2008
Reputation:
6
Hi Craven,
Hmm... historically, I've always found that if files aren't getting uploaded it's because of either of the following two causes:
1. the settings on the file field are two restrictive, e.g. they only permit file types of a certain format or size
2. the PHP config has been told to disregard files over a certain file size
You've probably checked into them, but if not I'd start there. If it's working sporadically, I doubt it's a problem with the FT upgrade or migration.... but still, doing a fresh install as a base test is never a bad idea.
Regarding the filename changes: yes, you're quite right about Form Tools occasionally renaming files. In the past, I received a number of bug reports in which files were uploaded with filenames that were valid on the system in which they were created, but not by the server that they get uploaded to. For example, if the file contained spaces, non-ascii or UTF-8 characters, it could cause any number of issues down the line. So to cover all scenarios, in 2.0.1 I added a new variable to library.php: $g_filename_char_whitelist
That specifies all the permissable characters in a filename, any other characters are stripped out. Feel free to override that setting, but don't override it there: just add that variable to your config.php so you can upgrade safely.
Hope you get to the bottom of this.
- Ben