jeudi 8 novembre 2018

File not found no matter what method is used in a laravel project

i've created a laravel project where i upload some zip files into storage/app/public like so:

public function uploadAddon(Request $request){
    $path = $request->file('zipFile')->storeAs('public', 'addon-01');
    dd($path);
}

I've created the symbolic link as mentioned in docs. but, when i try to find the file i always get FALSE no matter which method i use, file_exsists() or File::find or asset('/storage/public/filename.ext'), even though the path is correct and the file does exist in the storage !! here is the code :

public function RequestAddon(int $id)
{
    $fileurl = public_path(). "/storage/public/addon-01.zip";
    // Storage::url('addon-01.zip'))
    // $fileurl = asset('/storage/public/addon-01.zip');

    dd(array(File::exists($fileurl), $fileurl));
    if (file_exists($fileurl)) {
        return Response::download(
            $fileurl,
            'addon-01.zip',
            array('Content-Type: application/octet-stream', 'Content-Length: ' . filesize($fileurl)));
    } else {
        dd('no such file');
    }
}

here is the execution for the snippet above:

    array:2 [▼
  0 => false
  1 => "/home/joe/Public/Projects/repo/public/storage/public/addon-01.zip"
]

i spent more than hours figuring and trying different solution but the same output, SO any help, please?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire