4 years ago

How to View a PDF file in the browser

Posted 4 years ago by Khudadad

I want to make a link to a pdf file, when visitor clicks on it, it should be viewed in the browser instead of download, but can't and I'm getting this error:

FileNotFoundException in File.php line 37: The file "{"id":3,"title":"sdfdf","isbn":"2323","author":"sfsf","description":null,"size":203932,"book_path":"books\/2015_EX_1.pdf","user_id":2,"category_id":0,"created_at":"2015-11-17 02:04:54","updated_at":"2015-11-17 02:04:54"}" does not exist

This is my function:

public function readBook($id)
    $file = Book::findOrFail($id);
    if (File::isFile($file))
        $file = File::get($file);
        $response = Response::make($file, 200);

        $response->header('Content-Type', 'application/pdf');

        return $response;

any help thanks

Please sign in or create an account to participate in this conversation.