7 months ago

Redirect view after download pdf

Posted 7 months ago by vinubangs

Below is method in controller. I want to download pdf file and then redirect on view. How can it be possible?

public function insertdownloadpdf(Request $request)
        $userdetails = new userdetail;

       $userdetails->name = $request->name;
       $userdetails->email = $request->email;
       $userdetails->designation = $request->designation;
       $userdetails->organisation = $request->organisation;
       $userdetails->number = $request->number;
       $pdffile = $request->pdfname;
       session()->put('username','Successfully Inserted');

     $file= public_path(). "/storage/upload_pic/";  //path of your directory
                $headers = array(
                    'Content-Type: application/pdf',
        return Response::download($file.$pdffile, 'articles.pdf', $headers);

         $journals = journal::all();
        $articles = article::where('volume_id',$request->volume_id)->with('journal','volume')->get();
       return view('viewarticles',compact('journals','articles'));

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