I am trying to copy images for a newsletter from the media folder to a folder in my assets folder for persistence.
For that I created a page.update:after hook (in the config.php), that tries to utilize F::copy. That fails.
Using F::exists($newPage->banner()->toFile()->crop(600, 258)->url()) for debugging returns false (or nothing?). Looking in the corresponding media subfolder, the file is there. Under the exact same path, $newPage->banner()->toFile()->crop(600, 258)->url() returns.
This is the code I am rying to use for the copying (where DS is the DIRECTORY_SEPARATOR):
F::copy($newPage->banner()->toFile()->crop(600, 258)->url(), $_SERVER['DOCUMENT_ROOT'] . DS . 'assets' . DS . 'newsletter-images' . DS . $newPage->slug() . DS . $newPage->banner()->toFile()->crop(600, 258)->filename(), true);
What could this be? Or am I appoarching this completely from the wrong angle?