# Deleted audio file still visible in frontend

**URL:** <https://forum.getkirby.com/t/deleted-audio-file-still-visible-in-frontend/20511>\
**Category:** Questions\
**Tags:** v3\
**Created:** [December 23, 2020, 8:03pm UTC](https://forum.getkirby.com/t/deleted-audio-file-still-visible-in-frontend/20511 "2020-12-23T20:03:54Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![mafleig](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/mafleig/32/15806_2.png) [@mafleig](https://forum.getkirby.com/u/mafleig)\
**Post date:** [December 23, 2020, 8:03pm UTC](https://forum.getkirby.com/t/deleted-audio-file-still-visible-in-frontend/20511/1 "2020-12-23T20:03:55Z")

</div>

Hi,

I have a files field for audio files which works fine when the file is uploaded, but when i delete it it’s still visible. what’s wrong here? problem occurs on the live server (php 7.4).

blueprint:

```
  audio:
    type: files

```

template:

```
<?php if ($page->audio()->isNotEmpty()): ?>
    <div>
    <h2>Audio</h2>
<?php foreach($page->audio() as $audio): ?>
<audio controls>
  <source src="<?= $audio->url() ?>" type="<?= $audio->mime() ?>">
</audio>
<?php endforeach ?>
</div>

<?php endif ?>

```

---

<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:** [December 23, 2020, 8:22pm UTC](https://forum.getkirby.com/t/deleted-audio-file-still-visible-in-frontend/20511/2 "2020-12-23T20:22:17Z")

</div>

> [@mafleig](#):
>
> have a files field for audio files which works fine when the file is

The reason why your code works at all is that [`audio`](https://getkirby.com/docs/reference/objects/page/audio) is a custom Kirby method that fetches all audio files from your page, not the ones selected in your files field. If you were fetching the field, the code wouldn’t work, because you can’t loop through a field object.

What you have to do, is convert your field content into a file object (single file) or files collection.

```auto
<?php
// because `audio` is a native page method, we have to go via the content object (or you have to rename your field to something else)
$audioFiles = $page->content()->get('audio')->toFiles();
if ( $audioFiles->isNotEmpty() ) : ?>
<div>
    <h2>Audio</h2>
<?php foreach($audioFiles as $audio): ?>
<audio controls>
  <source src="<?= $audio->url() ?>" type="<?= $audio->mime() ?>">
</audio>
<?php endforeach ?>
<?php endif; ?>

```

---

<div class="post-metadata">

**Author:** ![mafleig](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/mafleig/32/15806_2.png) [@mafleig](https://forum.getkirby.com/u/mafleig)\
**Post date:** [December 23, 2020, 8:43pm UTC](https://forum.getkirby.com/t/deleted-audio-file-still-visible-in-frontend/20511/3 "2020-12-23T20:43:14Z")

</div>

Aah, perfect! Thanks @texnixe 🙂
