How to download file in laravel?

File name : index.php

Route::get('downloadFile', 'DownloadFileController@downloadFile');

Controller

<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;

class DownloadFileController extends Controller
{

public function downloadFile()
{
$myFile = public_path("itech.pdf");
$headers = ['Content-Type: application/pdf'];
$newName = 'itechxpert-pdf-file-'.time().'.pdf';

return response()->download($myFile, $newName, $headers);
}
}





Previous Next


Trending Tutorials




Review & Rating

0.0 / 5

0 Review

5
(0)

4
(0)

3
(0)

2
(0)

1
(0)

Write Review Here


Ittutorial