🧐😒 Download File from URL to Storage Example, Download File From URL to Public Storage Folder (ok)
https://www.itsolutionstuff.com/post/laravel-download-file-from-url-to-storage-exampleexample.html
Example :


C:\xampp8\htdocs\oec\routes\web.php
<?php
use App\Http\Controllers\DemoController;
use Illuminate\Support\Facades\Route;
/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/
Route::get('/', [DemoController::class,'index']);
C:\xampp8\htdocs\oec\app\Http\Controllers\DemoController.php
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Storage;
class DemoController extends Controller
{
/**
* Write code on Method
*
* @return response()
*/
public function index(Request $request)
{
$path = "https://www.itsolutionstuff.com/assets/images/logo-it.png";
Storage::disk('local')->put('itsolutionstuff.png', file_get_contents($path));
$path = Storage::path('itsolutionstuff.png');
return response()->download($path);
}
}
Last updated
Was this helpful?