vendredi 29 octobre 2021

Laravel public_path is showing entire site URL

I finally figured out I can just use my laravel public folder for storing these PDF files I need to display on a web page, but the way I'm getting them fails to load on the front-end.

I just realized it's because public_path shows the whole URL like C:\user\user1\websites\public\test1.pdf where I'm expecting it to just show /test1.pdf

Why is this code resulting in the full URL like that

    $file1 = 'test1.pdf';
    $file2 = 'test2.pdf';

    if(file_exists(public_path($file1))){
        $files[1] = public_path($file1);
    }

    if(file_exists(public_path($file2))){
        $files[2] = public_path($file2);
    }

    $PDFfiles = json_encode($files);

    dd($PDFfiles);


via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire