Forums

URL of uploaded file into mail

marcielo 12 Apr, 2011
Hi

I'm trying to get the code for inserting the URL of the uploaded file into the mail to work.
I changed [file_1] ---> [file_5]

I inserted the code (the one from book) within the 'On Submit code - before...' box
<?php
// get the form uploads information
$MyUploads =& CFUploads::getInstance($MyForm->formrow->id);
// extract the file path
$file_path = $MyUploads->attachments[file_5];
// remove the 'root folder' from the beginning
$file_url = substr($file_path, strlen(JPATH_SITE)+1);
//correct any mis-directed separators
$file_url = str_replace(DS, '/', $file_url);
// add the domain name to the beginning
$file_url = JURI::base().$file_url;
// save the URL into the form results
JRequest::setVar('file_url', $file_url);
?>


In the mail template I have {file_5}. But the only thing I get in the mail (+debug) is the file name (with date) and the extension of the file (.jpg)

The deeper purpose of this is to get the URL inserted into SugarCRM

Can someone explain if I am missing something😟 ?

I use Chronoforms 3.1 RC5.5 and Joomla 1.5.23
GreyHead 12 Apr, 2011
Hi marcielo,

Please will you add quotes round file_5 in this line
$file_path = $MyUploads->attachments['file_5'];
and add {file_url} to the Email template.

Bob

There's been another thread around exactly this already this week - except that was for posting to SalesForce I think.
marcielo 13 Apr, 2011
Thank you Bob!

I was missing {file_url} in the template😶

Please will you add quotes round file_5 in this line



It doesn't say so in the book and it works fine without the quotes.

I'll take a look at the thread.
GreyHead 13 Apr, 2011
Hi marcielo,

Thanks for confirming that the quotes aren't needed. To me the code looks a bit bare without them :-)

Bob
marcielo 13 Apr, 2011
I checked the following thread that I think
you were referring to.
http://chronoengine.com/forums/index.php?option=com_chronoforums&cont=posts&f=2&t=21409

I did:

add a hidden input in the Form HTML with name='file_url' then you can use this to pass the updated value through cURL.



But I get the same issue as in the thread above. I can see that the value is entered in the table, but is not passed through the cURL. I did debug the cURL and I can see that it doesn't pass. I have to mention that I have other fields like 'name' and 'last name' and those values pass fine through the cURL.

You mention that:

There were a few small problems but mostly it was a bug in the cURL Plug-in that forced it to run Before Email



Does it have something to do with that ? I use Chronoforms 3.1 RC5.5
GreyHead 13 Apr, 2011
Hi marcielo,

I think the problem with the other thread was a bug in the plug-in that meant that you could only set the plug-in to 'Before Email. Is that what you see?

Bob
marcielo 13 Apr, 2011
Yes, that's what I see, I can't save it as 'After email'

Great I got your fix from the other post and it works:


In components/com_chronocontact/plug-ins/cf_CURL.php look fro this line around line 200 and comment it out or delete it:


 $hidden_array['params[onsubmit]'] = 'before_email';

This topic is locked and no more replies can be posted.