Hi.
I hope somebody can help me with this.
I have the following code I can't get to work in the body of a connection. What I'm trying to achieve is create a link to a file only if a file has been uploaded via a Chrono Form, and to show something else if there's no file.
If there's a file it does create the correct link (components/com_chronoforms/uploads/CondAdminForm/XYZ.jpg), but if there's no file, instead of showing "no file" the link is incomplete, with no file at the end (components/com_chronoforms/uploads/CondAdminForm/)
What's wrong?
Thanks!
I hope somebody can help me with this.
I have the following code I can't get to work in the body of a connection. What I'm trying to achieve is create a link to a file only if a file has been uploaded via a Chrono Form, and to show something else if there's no file.
<tr>
<td>
<?php
if
(file_exists('components/com_chronoforms/uploads/CondAdminForm/' . $row['letter']))
{
echo '<a href="components/com_chronoforms/uploads/CondAdminForm/' . $row['letter'] . '">letter</a>';
} else {
echo "no file";
}
?>
</td>
</tr>
If there's a file it does create the correct link (components/com_chronoforms/uploads/CondAdminForm/XYZ.jpg), but if there's no file, instead of showing "no file" the link is incomplete, with no file at the end (components/com_chronoforms/uploads/CondAdminForm/)
What's wrong?
Thanks!
Hi sarkomand,
I would make the file urls absolute. Avoid relative URLs in Joomla as the same content can be loaded from different folders.
Bob
Bob
I would make the file urls absolute. Avoid relative URLs in Joomla as the same content can be loaded from different folders.
<tr>
<td>
<?php
if (file_exists(JPATH_SITE.'/components/com_chronoforms/uploads/CondAdminForm/'.$row['letter'])) {
echo "<a href='".JURI::root()."components/com_chronoforms/uploads/CondAdminForm/{$row['letter']}' >letter</a>";
} else {
echo "no file";
}
?>
</td>
</tr>
Bob
Bob
Thanks, Bob.
Unfortunatelly I get the same result. It seems like the "file_exists" thing is checking for any file in any row and not for a file in that specific row.
So, If I do
I get "yes file" even in the rows of the entries with no file uploaded.
Unfortunatelly I get the same result. It seems like the "file_exists" thing is checking for any file in any row and not for a file in that specific row.
So, If I do
<?php
if
(file_exists(JPATH_SITE.'/components/com_chronoforms/uploads/CondAdminForm/' . $row['letter']))
{
echo "yes file";
} else {
echo "no file";
}
?>
I get "yes file" even in the rows of the entries with no file uploaded.
Hi,
Maybe you get yes in rows with no files because when the file name is empty, then it checks the folder path, which always exists, you should add this to the if statement:
Regards,
Max
Maybe you get yes in rows with no files because when the file name is empty, then it checks the folder path, which always exists, you should add this to the if statement:
AND !empty($row['letter'])
Regards,
Max
This topic is locked and no more replies can be posted.