Laravel, trying to use helper to display PDF

Multi tool use
Multi tool use


Laravel, trying to use helper to display PDF



I'm trying to display a PDF file I have in my storagereports folder inline in the browser.



My file is: storagereportsReal_Estate_Test.pdf


storagereportsReal_Estate_Test.pdf



I have a helper file: appHelpershelpers.php


appHelpershelpers.php



I call the PDF from my blade with: {{viewReport($filepath, $ext, $filename)}}


{{viewReport($filepath, $ext, $filename)}}



where


$filepath = storage_path().'reports';
$ext = "pdf";
$filename = "Real_Estate_Test";



In my helper file I have:


<?php

use Response;

if (! function_exists('viewReport'))
{
function viewReport($filepath, $ext, $filename)
{
$filename.".".$ext, , 'inline');

$headers = [
'Content-Type' => 'application/pdf',
'Content-Disposition' => 'inline; ' . $filepath."\".$filename.".".$ext,
];

return Response::make(File::get($filepath."\".$filename.".".$ext), 200, $headers);

}
}



In my composer.json I have:


"autoload": {
"classmap": [
"database"
],
"psr-4": {
"App\": "app/"
},
"files": [
"app/Helpers/helpers.php"
]
},



I get this error at the top of my page:


Warning: The use statement with non-compound name 'Response' has no effect in C:xampphtdocsDS_dev_01appHelpershelpers.php on line 4



where line 4 is use Response;


use Response;



If I comment out line 4 I then get nothing.



I've also tried doing this with this suggestion from another post:


return response()->download($filepath."\".$filename.".".$ext, $filename.".".$ext, , 'inline');



and I get the following string displayed at the top of my page (no PDF):


HTTP/1.0 200 OK Cache-Control: public Content-Disposition: inline; filename="Real_Estate_Test.pdf" Date: Sat, 30 Jun 2018 18:21:48 GMT Last-Modified: Sat, 30 Jun 2018 18:21:48 GMT



which looks really close to a command to load and display my PDF.



Any suggestions as to what I'm doing wrong. Trying to piece together hints from Laravel docs and many posts is not getting me anywhere.



I'm running Laravel 5.5 on XAMPP in Win10 with PHP7



Thanks in advance









By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

LaTILZS1Fa8pnsP8wEx,wfVYkkfQpZ9N9hGl,0BzfmGPIB2Xa2PI1FG2cu
Kq4U1 ay0O jOSCbfltelp2BbG,etc LaGON9Bv

Popular posts from this blog

PySpark - SparkContext: Error initializing SparkContext File does not exist

django NoReverseMatch Exception

Audio Livestreaming with Python & Flask