您好,我正在尝试从数据库中获取所有电子邮件,然后将它们输出到文本(逗号分隔)文件中。这是我已经完成但不起作用的操作:
public function get_textfile() {
$emails = Staff::get('email');
header("Content-type: text/csv");
header("Cache-Control: no-store, no-cache");
header('Content-Disposition: attachment; filename="filename.txt"');
$stream = fopen("php://output", 'w');
foreach($emails as $email) {
fputcsv($stream, $email, ',');
}
fclose($outstream);
}
return (something)?
得到这个:错误6(net :: ERR_FILE_NOT_FOUND):找不到文件或目录。
这是我的路线:
Route::get('textfile', array('as' => 'textfile','uses' => 'admin@textfile'));