# Filetype returning whole string

**URL:** <https://forum.getkirby.com/t/filetype-returning-whole-string/8857>\
**Category:** Questions\
**Tags:** v2\
**Created:** [October 25, 2017, 8:13pm UTC](https://forum.getkirby.com/t/filetype-returning-whole-string/8857 "2017-10-25T20:13:23Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![bbarclay](https://avatars.discourse-cdn.com/v4/letter/b/96bed5/32.png) [@bbarclay](https://forum.getkirby.com/u/bbarclay)\
**Post date:** [October 25, 2017, 8:13pm UTC](https://forum.getkirby.com/t/filetype-returning-whole-string/8857/1 "2017-10-25T20:13:23Z")

</div>

```auto
                <p>File Size: <?= $event->callToActionFile()->extension() ?> </p>
            <?php endif ?>

```

I’m using -\>extention() or -\>file() and it’s returning the whole file name instead of just .pdf or .xls it’s coming out

brandon.xls or something.pdf any suggestion on how to trim this or make it just show the file extension?

Thanks

---

<div class="post-metadata">

**Author:** ![texnixe](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/texnixe/32/5754_2.png) [@texnixe](https://forum.getkirby.com/u/texnixe)\
**Post date:** [October 25, 2017, 8:26pm UTC](https://forum.getkirby.com/t/filetype-returning-whole-string/8857/2 "2017-10-25T20:26:33Z")

</div>

I suppose the field `callToActionFile` contains a filename?

```auto
<?php
$file = $event->callToActionFile()->toFile();
if($file) {
  echo $file->extension();
}

```

---

<div class="post-metadata">

**Author:** ![bbarclay](https://avatars.discourse-cdn.com/v4/letter/b/96bed5/32.png) [@bbarclay](https://forum.getkirby.com/u/bbarclay)\
**Post date:** [October 25, 2017, 10:02pm UTC](https://forum.getkirby.com/t/filetype-returning-whole-string/8857/3 "2017-10-25T22:02:43Z")

</div>

Worked thank you. 🙂

---

<div class="post-metadata">

**Author:** ![distantnative](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/distantnative/32/11319_2.png) [@distantnative](https://forum.getkirby.com/u/distantnative)\
**Post date:** [February 6, 2025, 5:31pm UTC](https://forum.getkirby.com/t/filetype-returning-whole-string/8857/4 "2025-02-06T17:31:50Z")

</div>


