Not returning whole path

I have this code. It will not return the whole path. It just returns the base url. Any idea how to fix this.

  <? echo $file = $item->postimage()->tofile();
                                   $getFile = $file->url();

                                <?php echo $site->url() ?>

it will return localhost:8888/image.png
instead of localhost:8888/marketing/image.png it’s leaving off the directory that the image is stored in.


What do you want to echo here? The image? Or the URL?


$file = $item->postimage()->toFile(); //note the capital F
if($file) echo $file->url();

Or echo an image:

<?= $item->postimage()->toFile(); ?>

The capital F fixed it for me. Thanks