radha's avatar
Level 1

Passing file contents from controller to view

Hi, I want to show my uploaded file contents in my view page. am getting the file contents in decrypted form.

Below is my controller.php:

if($ext == 'pdf' ) { $file = File::get($file); $response = Response::make($file, 200); $response = $response->header('Content-Type', 'application/pdf' ); Session::flash('message',$response); return Redirect::back(); }

and this is my view.php:

if (Session::has('message')) { {{ Session::get('message'); }} }

0 likes
2 replies
radha's avatar
radha
OP
Best Answer
Level 1

We can send file in flash, But we have to send in base64 encode format. this will work.

$file = $request->file('uploadfile'); $file = File::get($file); $base64= "data:"."$mime;base64,".base64_encode($file); Session::flash('message',$base64); return Redirect::back();

view.php

Please or to participate in this conversation.