Permission denied error on CSV export Laravel -
i using laravel 4. when try export database table csv file error,
fopen(file.csv): failed open stream: permission denied
this code,
public function getexport(){ $table = users::all(); $filename = "file.csv"; $handle = fopen($filename, 'w+'); fputcsv($handle, array('name', 'status')); foreach($table $row) { fputcsv($handle, array($row['name'], $row['status'])); } fclose($handle); $headers = array( 'content-type' => 'text/csv', ); return response::download($filename, 'tweets.csv', $headers); }
how can fix ?
try chmod 777 file.csv
on terminal , run php again
Comments
Post a Comment