Create File In Laravel

[Solved] Create File In Laravel | Php - Code Explorer | yomemimo.com
Question : create file in laravel

Answered by : indian-gooner

namespace App\Http\Controllers;
use File;
class FileController extends Controller
{ public function downloadJSONFile(){ $data = json_encode(['Element 1','Element 2','Element 3','Element 4','Element 5']); $file = time() .rand(). '_file.json'; $destinationPath=public_path()."/upload/"; if (!is_dir($destinationPath)) { mkdir($destinationPath,0777,true); } File::put($destinationPath.$file,$data); return response()->download($destinationPath.$file); }
}

Source : http://www.phpzone.in/laravel-5-create-a-json-or-text-file-using-file-system/ | Last Update : Mon, 17 May 21

Question : laravel store file

Answered by : faithful-fox-26fckddxsm2c

$path = $request->file('avatar')->store( 'avatars', 'public'
);

Source : https://stackoverflow.com/questions/44045474/storing-and-retrieving-stored-file-in-laravel-5-4 | Last Update : Sat, 12 Dec 20

Answers related to create file in laravel

Code Explorer Popular Question For Php