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

Popular posts from this blog

angularjs - ADAL JS Angular- WebAPI add a new role claim to the token -

php - CakePHP HttpSockets send array of paramms -

node.js - Using Node without global install -