Show icon only if file exists

I’m using the following code on the onRecord event, but it shows even when there’s no file. How do I get it to show only when there’s a file?


sc_lookup(ds, "SELECT file FROM int_bugs WHERE id = ".{id});
{link} = "<a href='../../../file/doc/bugs/{file}".{ds[0][0]}."' download><img src='https://domain.com/sc9/devel/conf/grp/BG/img/ico/downloadImage.png' height=18></a>";

You cau use file_exists ( string $filename )