Hello!
I'm using the following code to display a link only when the file exists:
The problem is it still displays the line "Descargar archivo" even when the file doesn't exist instead of displaying "No file", it's like the "else" wasn't there.
Can you help me please?
I'm using the following code to display a link only when the file exists:
<?php
if ($form->data["Banner2"]["documento_banner"] !== ' ') {
echo "<a href='*my path*/com_chronoforms5/chronoforms/uploads/banner2/{Banner2.documento_banner}'>Descargar archivo</a><br>";
} else {
echo "No file";
}
?>
The problem is it still displays the line "Descargar archivo" even when the file doesn't exist instead of displaying "No file", it's like the "else" wasn't there.
Can you help me please?
Hi nams09,
You are checking !== ' ' - and there is a space between the ' '. It should be '' with no space, or perhaps better:
Bob
You are checking !== ' ' - and there is a space between the ' '. It should be '' with no space, or perhaps better:
<?php
$message = 'No file';
if ( !empty($form->data['Banner2']['documento_banner']) ) {
$image_uri = JURI::root().'/com_chronoforms5/chronoforms/uploads/banner2/'.$form->data['Banner2']['documento_banner'];
$message = "<a href='{$image_uri }'</a><br>";
}
echo $message;
?>
Bob
Hi Greyhead!
Thanks for your reply. Unfortunately this didn't work, looks like it's not recognizing the !empty command, which is why I used !== ' ' instead. Any idea of what could be the problem?
Thanks for your reply. Unfortunately this didn't work, looks like it's not recognizing the !empty command, which is why I used !== ' ' instead. Any idea of what could be the problem?
Hi nams09,
The !empty() code should work correctly.
I notice that this is the ChronoConnectivity forum but this looks like a ChronoForms question - which is it?
If it is CF then $form->data will work, if it is CC then you probably need $row
Bob
The !empty() code should work correctly.
I notice that this is the ChronoConnectivity forum but this looks like a ChronoForms question - which is it?
If it is CF then $form->data will work, if it is CC then you probably need $row
Bob
This topic is locked and no more replies can be posted.