Forums

Posting URL of file upload to an external site

sayf00 05 Apr, 2011
Hi,

I had a look over the forum but couldn't find an answer, apologies if I have missed it.

I have an account with FLG360.co.uk, that handles lead management.

I'm using CF to submit leads directly into the system using the Submit URL option. Everything is working fine bar one problem.

We need images to be attached to our leads. FLG360 does not have this function so my thoughts on a work around are to have the URL of the image that is uploaded sent to a standard text field in FLG360, our sales team can then just copy and paste the link in their browser to see the image.

Can anyone suggest how this would be done? This is the code that I have for the text field from FLG360:
<label for="strLeadData1">Image URL:</label>
	<input type="text" name="strLeadData1" id="strLeadData1" value="" />


How can I replace this field with a file upload box that submits the URL of the file into FLG360?

Many thanks in advance
GreyHead 05 Apr, 2011
Hi sayf00,

Basically, you can't do what you suggest. When you use the OnSubmit URL then the form is submitted to that URL, ChronoForms and Joomla! never see the results so no file will be uploaded except to FLG360 and you say that can't handle them.

The alernative is not to use the OnSubmit URL, let ChronoForms handle the uploads and then pass the information via CURL or a ReDirect URL to FLG360. Then you can use one of the OnSubmit code boxes to add the image url to the data to be passed on.

Bob
sayf00 05 Apr, 2011
Thanks Bob,

Will give that a try now.

Sayf
sayf00 05 Apr, 2011
Right, I've got CURL working successfully but I'm still having a problem.

How do I get the file upload field to convert to a URL field that can be submitted into the text field in FLG360?

You mentioned onSubmit Bob, could you elaborate please?

Thanks
Sayf
GreyHead 05 Apr, 2011
Hi Sayf,

Here's a little extract from The ChronoForms Book.

Go back to the Form Editor, click the Form Code tab and then open the OnSubmit
code – before sending email text area. We're going to add some code in here (check
the comments to see what the each line of code does):

<?php
// get the form uploads information
$MyUploads =& CFUploads::getInstance($MyForm->formrow->id);
// extract the file path
$file_path = $MyUploads->attachments[file_1];
// 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);
?>


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

Bob

PS You must have Send Emails set to Yes on the form General Tab for the OnSubmit Before Email code to be executed.
sayf00 05 Apr, 2011
Hi Bob,

Thanks for the reply. Really close now.

I've tried your code. The file_url field is correctly holding the URL as I've checked the database but it's not passing through to FLG.

If I use the code you gave but link the file upload field directly in CURL ignoring the file_url hidden input then the file name passes through to FLG but not the URL.

Any ideas?
GreyHead 05 Apr, 2011
Hi Sayf,

May be a question of the sequence things are running in/ But that should be OK if you are using the OnSubmit Before Emaila box.

Ah it also may be this line
$file_path = $MyUploads->attachments['file_1'];
You need to replace file_1 with the name of the file input from your form. Please check that.

Bob
sayf00 05 Apr, 2011
Hi Bob,

I have the correct file name in the code (file_27) and the file_url field is populating in the Joomla database fine. It just won't send over to FLG.

It does sound like a sequencing issue, I changed the run order of the plugin but it didn't have any effect.

Is there any code I can put in the "Extra Code" tab in the CURL settings?

As mentioned the file_27 field if linked to the text field in FLG does send the filename, could that part be tweaked?

Thanks for all your help so far

Sayf
GreyHead 06 Apr, 2011
Hi Sayf,

Please turn on the CURL debug and post the results here (or PM them to me if you prefer).

Bob
sayf00 06 Apr, 2011
Hi Bob,

Please see below, i've replaced any reference to the domain with xxxxx.

JFile::read: Unable to open file: '/home/xxxxxx/public_html/components/com_chronocontact/css/plugin.css'

cf_CURL debug info
$curl_values: strLeadFirstName=hghgjhk&strLeadLastName=uytyutyu&strLeadEmail=dsfdfd%40sdfd.com&strLeadPhone1=76786786&strLeadPhone2=6876876&strLeadData2=4th+April&strLeadData1=&intLeadGroupID=9622&strSource=&strMedium=&strTerm=&intSiteID=&ntReferrerBuyerID=&strAPISuccessURL%27=http%3A%2F%2Fxxxxxxx.co.uk%2Fthank-you&strAPIFailUR=http%3A%2F%2Fxxxxxx.co.uk%2F404&strLeadAddress=&strLeadAddress2=&strLeadAddress3=&strLeadTownCity=&strLeadPostcode=&strLeadData3=&strLeadData4=&strLeadData5=&strLeadData6=&strLeadData7=&strLeadData8=&submit=Download
$params->target_url: http://xxxxxx.flg360.co.uk/api/APIHTTPPost.php
$ch: Resource id #116
CURL response: 1


Thanks
Sayf
GreyHead 06 Apr, 2011
Hi Sayf,

Ok - these are the paramters and values. Where does the file url belong here? Ther's no obvious parameter to pass it.
strLeadFirstName=hghgjhk
strLeadLastName=uytyutyu
strLeadEmail=dsfdfd%40sdfd.com
strLeadPhone1=76786786
strLeadPhone2=6876876
strLeadData2=4th+April
strLeadData1=
intLeadGroupID=9622
strSource=
strMedium=
strTerm=
intSiteID=
ntReferrerBuyerID=
strAPISuccessURL%27=http%3A%2F%2Fxxxxxxx.co.uk%2Fthank-you
strAPIFailUR=http%3A%2F%2Fxxxxxx.co.uk%2F404
strLeadAddress=
strLeadAddress2=
strLeadAddress3=
strLeadTownCity=
strLeadPostcode=
strLeadData3=
strLeadData4=
strLeadData5=
strLeadData6=
strLeadData7=
strLeadData8=
submit=Download

Bob
sayf00 06 Apr, 2011
strLeadData1 should be the file_url.

When strLeadData1 is set to file_27 in CURL I get the filename appearing. When set to file_url it's blank as in the post above.

Thanks
Sayf
GreyHead 06 Apr, 2011
Hi Sayf,

Thank you. I think I may have found the problem. Please go back to my original code where the last line is
JRequest::setVar('file_url', $file_url);
and replace it with
$file->data['file_url'] = $file_url;


I suspect that Max has changed the coding in V4 so that he no longer reads the $_POST array after the initial upload. It seems that you now have to modify $file->data instead.

Bob
sayf00 06 Apr, 2011
Sorry maybe I should have said, but I'm using 3.1 RC5.5.

I tried the changed of code, but still no joy.

Sayf
sayf00 11 Apr, 2011
Sorry to bump but anyone have any ideas?

Happy to provide login via pm for someone to take a look.

Thanks
GreyHead 11 Apr, 2011
Hi Sayf,

I'm not sure what else to try with this. Is it still not working?

By all means email or PM me the site URL and a SuperAdmin login and I'll take a quick look.

Bob
GreyHead 11 Apr, 2011
Hi Sayf,

It's working now - or at least the URL is in the CURL parameters for the FLG360 form.

There were a few small problems but mostly it was a bug in the cURL Plug-in that forced it to run Before Email - which also means before the OnSubmit Before box. I installed exTplorer to fix the bug it's free Joomla! file browser extension; you can leave it installed or delete it.

Bob
sayf00 11 Apr, 2011
Hi Bob,

Thanks for a taking a look.

Unfortunately it's still not working. In FLG360 I still only get the file title not the full URL.

Sayf
GreyHead 12 Apr, 2011
Hi Sayf,

As you can see from the image below, the full url (in urlencoded format) is being passed by the cURL command so I'm not sure what else you are looking for?

Bob
sayf00 18 Apr, 2011
Hi Bob,

Sorry, yes it is working. However there is another installation of Joomla! within the domain. Can you tell me what the fix was, so I can implement it on the other site.

Many Thanks
Sayf
GreyHead 18 Apr, 2011
Hi Sayf,

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';


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