laravel storage get file path
use Illuminate\Support\Facades\Storage;
$path = Storage::path('file.jpg');
laravel storage get file path
use Illuminate\Support\Facades\Storage;
$path = Storage::path('file.jpg');
create file in laravel
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);
}
}
laravel store file
$path = $request->file('avatar')->store(
'avatars', 'public'
);
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us