Reputation: 3
So I wanna get the file from my item and save it to my server but I cant seem to get file id from item. How do I do it? When I view the item details via PodioItem:get the file details i only get are:
[files] => Array
(
[type] => File
[options] => Array
(
[json_value] => file_id
[json_target] => file_ids
)
)
I wanna know how to get the file id of the item then i am planning to use the PodioFile::get_raw( $file_id );
code to get the file
I would really appreciate the help
Upvotes: 0
Views: 156
Reputation: 644
You can get an item by using the API
$item = PodioItem::get($itemID);
Also, you can get the files attached to an item by using $item->files
if ($item->files && count($item->files) > 0) {
foreach ($item->files as $fileID) {
$file = PodioFile::get($fileID);
$fileRaw = $file->get_raw();
// save the file
file_put_contents($yourPathToSaveFile, $fileRaw);// make sure you have permission to save the file to the location
}
}
Upvotes: 1