Jump to content

PageTable file->url only returns path to folder


simonGG
 Share

Recommended Posts

Hi there,

i run in an strange behavior when using the PageTable field. 
I have a PageTable field named upload - the template for this field has following fields:

file (file field)
nums (table field)
color (colorPicker field)

Now i try to get the url's for the uploaded files (in this case 1 PDF and 1 SWF)


$uploads = $page->upload;
foreach ($uploads as $upload) 
{
  $file = $upload->file;
  echo $file->url."<br>";
  echo $file->filename."<br>";
}

Which returns:

Upload 1
/DB-v2/site/assets/files/1060/

Upload 2
/DB-v2/site/assets/files/1061/

 

So you can see the URL only returns the path to the folder?
And the filename isnt reachable.

Anybody have a idea ? Thanks in advance and bye bye
Simon

Link to comment
Share on other sites

Getting just the folder means $file is actually not a file (Pagefile), but a Pagefiles object. File fields are internally always handled as list of files, so you might need to use the following or alike:

$file = $upload->file->first();
  • Like 3
  • Thanks 3
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...