jeudi 27 juin 2019

How to fix: Duplicating path when using fopen on Laravel?

I'm using laravel 5.1, i'm trying to send a file that my Laravel application creates to an api, in a http request, the file was created in the right place on my application, but when i try to read this with fopen to append on the body of request, it gives the follow error:

fopen(/home/user/code/folder/application/storage//home/user/code/folder/application/storage/pdf/group/38/file.pdf): failed to open stream: No such file or directory {"exception":"[object] (ErrorException(code: 0):

I tried to use a laravel feature called "Storage" (https://laravel.com/docs/5.1/filesystem), but when i use that, i have unknown errors to send by a GuzzleHttpRequest, then it works when i using an existing path with fopen

The code that get the file to send is:

fopen(storage_path("{$doc->filepath}/{$doc->id}/{$doc->name}"), 'r');

It working when was like that:

fopen("../{$doc->filepath}/{$doc->id}/{$doc->name}"), 'r');

The path that i need to get is "/home/user/code/folder/application/storage/pdf/group/38/file.pdf"



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire