I want to automatically store existing file json without change file name. Anyone can help me?
This is my code
class jsonDownload extends Controller
{
public function downloadJSONFile(){
$data = json_encode(DB::table('tabel')->get()->toArray());
$fileName = '1562261772_datafile.json';
File::put(public_path('upload/json/'.$fileName),$data);
return Response::download(public_path('upload/json/'.$fileName));
}
}
when I download, it always store as 1562261772_datafile (1).json
I don't want download as number but i want overwrite it.