Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • Laravel 5.0 Creating Download CSV Link

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 1.22k
    Comment on it

    In Laravel, many times we may need to create a link to download sample CSV file. So that user can download sample CSV file from our website and upload correct formatted file.

    It's a very simple task and to accomplish that we need to follow following simple steps.

    Step 1 :- Creating a link to download sample CSV file in our view.

    {!! Html::link('admin/employee/sample-csv-download', 'Download Sample CSV', array("class" =>"btn btn-default", "style" => "")) !!} 
    

    Step 2:- Make a route configuration in your routes.php

    Route::get('admin/employee/sample-csv-download', function(){
        $headers = array( 'Content-Type' => 'text/csv');
        return Response::download('csv/sample.csv', 'sample.csv', $headers);
    });
    

    Step 3:- Create a folder in your public directory named as csv and add a file named as sample.csv

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: