Having a filename issue

Hi

I have got my head around uploading files and then being able to select/attach them to fields in the panel however I am getting an odd result that is causing my site to break:

53

I can’t see where the additional linebreak and " - " dash before the filename are coming from and this is subsequently causing my code to break when I try and call the file in my page template.

Ideally the page.txt would just read:

Cover: sketchbook_2cover.png
----
Spread: sketchbook_2spread.jpg

Thanks

That’s fine and how it should be. You have to call the toFile() method on the field.

if($file = $page->cover()->toFile()):
  echo $file->url();
}

Edit: The reason for the yaml format is that the files field can have multiple files. For compatibility reasons this format is also used if you set multiple to false.

1 Like