0
votes

I want to export some data(laravel collection ) as csv file.

public function exportTransaction()
{   
    $ticket=all();

    $filename=$customer['firstname']."_".date('Y-m-d').".csv";
    $file_path=storage_path(). "/transactions"."/".$filename;   
    $handle = fopen($file_path,"w+");
    fputcsv($handle, array('date'));

    foreach($ticket as $row) {
        fputcsv($handle, array($row['orderDate']));
    }

    fclose($handle);

    $headers = array(
        'Content-Type' => 'text/csv',
    );

    return Response::download($file_path, $filename, $headers);
}

This is my code. I'm getting this error

local.ERROR: exception 'Symfony\Component\HttpFoundation\File\Exception\FileNotFoundException' with message 'The file "/var/www/html/FootballTicketPad/geethu/bondcms/app/storage/transactions/we1_2018-03-20.csv" does not exist' in /var/www/html/FootballTicketPad/geethu/bondcms/vendor/symfony/http-foundation/File/File.php:37

1
File doesn't exist. The error is fairly obvious.Andrei
There's nothing to correct. The code isn't necessarily wrong, the file simply doesn't exist.Andrei
It was the permission issue.Geethu

1 Answers

0
votes

It was the permission issue

cd storage

chmod -Rv 777 transcations