Forums

Email GH - using php in the File Attachments field

kaejai 01 Aug, 2012
Hi there

I am using Joomla 2.5.6, Chronoforms 4 v3.4.1

I have created a large, tabbed form which posts successfully.

On Submit I have custom code in which I generate and save a word doc with the form data. I generate a unique name for this file when I create it and I save it to one of the site folders. This saves successfully. I assign the newly generated file's name to a php session variable.

I wish to use the Email GH core action to then send this file. I have used Email GH successfully to attach the cv that has been uploaded during the form submit. I can upload the now existing created word file if I type in the full address and file name.

In the Email GH action, in it's General tab, in the File Attachments field I'd like to use the php session variable to address the new word doc so it can be attached.

I can use the format {filename} to attach an uploaded file, {#path#...etc} to attach an existing file. Can I use a php variable here? Or do you know of a better way that I can approach this problem?

Thanks for your superb extension and thanks for any help you can send my way
Kaejai
GreyHead 02 Aug, 2012
Hi Kaeiji,

This should be possible. But there is a catch :-( if the entry in the Attachments box starts with { AND ends with } then the action looks for the file path in the $form->files array. Otherwise it tries to parse the entry to find a file path.

This means that if your entry starts with {#path#} and ends with {file_name} then it isn't correctly interpreted.

The best workaround that I can think of is to add the file path to $form->files['file_name']['path'] using a Custom Code action and then use {file_name} in the Attachments box.

Bob

PS I'll update the action to avoid this problem by checking for multiple curly brackets. the fix is to change line 215 of email_gh.php to be
if ( substr( $v, 0, 1 ) == '{' && substr( $v, -1, 1 ) == '}' && strpos('{', $v, 1) === false) {
This topic is locked and no more replies can be posted.