<?php
$path = JPATH_SITE.'/components/com_chronoforms5/uploads/folder_name/';
$form->files['field_name']['path'] = $path.'file_name.jpg';
?>
but it does not seem to work with Chronoforms v6.
The problem is that the email does not start,
in fact the debugger gives me this view: files] => Array
(
[0] => guide
)
[result] => the Mail could not be sent.
Thanks to everyone who wants to help me
If this is the same file each time you can add the full file path to the Attachments list box in the Email action.
Bob
This is an old thread but my issue is the same. I have a dropdown choice list that the visitor can chose from as to what he needs to download. As per the choice an email goes to the visitor with the chosen file as an attachment.
I used this code in CFV5 successfully:
<?phpI cannot seem to succeed in doing it in CFV6.
switch ($_POST['select1'])
{
case 'File 1':
$form->files['catalog'] = array(
'path' => '/home/xyz/public_html/cat/file1.pdf'
);
break;
case 'File 2':
$form->files['catalog'] = array(
'path' => '/home/xyz/public_html/cat/file2.pdf'
);
break;
}
?>
I used a custom code block with this code and named it as "attach_file" and in the attachment list of the email I added {var:attach_file} but I do not get it to work.. The email is sent successfully but without any attachment.
Please suggest where am I going wrong.
Thanks
Ron
switch($this->data("field_name"))and
$this->set("var_name", "value")and use {var:var_name} in the email attach files field. Or just return the file path string, and use {var:phpname}
Or use a switch action, data source {data:fieldname}, returning the path (shouldn't need to be an array unless you're needing to upload multiple files)
Thanks for the help. You mean my code should be like this :
<?php
switch($this->data("select1"))
{
case 'File 1':
$this->set('attach_file', 'value') = array(
'path' => '/home/xyz/public_html/cat/file1.pdf'
);
break;
case 'File 2':
$this->set('attach_file', 'value') = array(
'path' => '/home/xyz/public_html/cat/file2.pdf'
);
break;
}
?>
Well it does not work and the submission hangs on submit. The debugger does not show anything. Maybe I am making a mistake somewhere.
Ron
<?php
switch ( $this->data( "File 1" ) ) {
case 'File 1':
$this->set( 'attach_file', 'File 1' ) = array(
'path' => '/home/xyz/public_html/cat/file1.pdf'
);
break;
}
switch ( $this->data( "File 2" ) ) {
case 'File 2':
$this->set( 'attach_file', 'File 2' ) = array(
'path' => '/home/xyz/public_html/cat/file2.pdf'
);
break;
}
?>
$this->set("var_name", "the actual value you want var_name to be");
But really just use a switch action (not event switcher). What you're doing doesn't need to be done in PHP.
I know switcher could be easy. But I don't know haw to put the values there. I tried reading the manual but could not het it to work.
Thanks
Ron
Data source should be {data:dropdownfieldname}
Then you have
optionvalue:texttoreturnSo you would for example have
file1:path/to/the/file.pdf
By the way your switch syntax is all over the place.
This is what was confusing me. I am going to try now.
Thanks again..
Ron
The debugger gives this output but no email is being sent :

Thanks for all the help
Ron
What error does the debug show
Thanks
The switch block may not work as it takes the path as an email. So the email sending fails and no attachment is establishes. I tried with custom code and also with php block. Nothing seems to work.
Any help I would greatly appreciate.
Thanks
Ron
Try just putting the path to one file directly in the file attach list and see if it sends
Try just putting the path to one file directly in the file attach list and see if it sends
Okay . I am going to do this.
Thanks for all the help.
Ron
Could not succeed in attaching any file. If I add anything in the attach Attachments settings it stops sending email.
I don't know what more to do.
