Skip to content

Instantly share code, notes, and snippets.

@sonichandni
Created February 20, 2024 10:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sonichandni/3eed51880ea03c5fb9a347209eda7ffe to your computer and use it in GitHub Desktop.
Save sonichandni/3eed51880ea03c5fb9a347209eda7ffe to your computer and use it in GitHub Desktop.
Laravel get store and get file from url
// Put file content
$client = new \GuzzleHttp\Client();
$response = $client->request('GET', $url);
$contents = $response->getBody()->getContents();
$fileName = $id . '_' . time() . '.pdf';
$path = 'public/bol/' . $fileName;
Storage::put($path, $contents);
// Get file content
$getUrl = asset("storage/bol/$fileName");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment