Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Where is the File::put() stored in Laravel?

Tags:

php

laravel

I have a question relating to Laravel, where is the File::put() stored in Laravel?

I have checked inside storage/app/public and the content isn't there.

like image 416
stat.us Avatar asked Oct 30 '16 03:10

stat.us


People also ask

What is storage folder in Laravel?

From Laravel official documentation. The storage directory contains compiled Blade templates, file based sessions, file caches, and other files generated by the framework. This folder is segregated into app, framework, and logs directories. The app directory may be used to store any files utilized by your application.

How do I get files in Laravel?

If you have file object from request then you can simply get by laravel function. $extension = $request->file->extension(); dd($extension); If you have file object from request then you can simply get by laravel function.

How do I upload files to storage in Laravel?

To upload files to storage in Laravel, use MAMP or XAMPP as a local web server, define a database name in MySQL, and add the correct configuration in the . env file.


2 Answers

To store files in folder storage/app, you must use Storage class as:

Storage::disk('local')->put('file.txt', 'Contents');

then it would store a file in storage/app/file.txt.

Docs

like image 66
Amit Gupta Avatar answered Sep 21 '22 02:09

Amit Gupta


File::put store in public folder

for example .In this case file.txt will be created in public folder

File::put('file.txt', 'contents is written inside file.txt');

Also you can use Storage class

Storage::put( 'file.txt','contents is written inside file.txt' );

This will create file inside storage\app

like image 32
Vision Coderz Avatar answered Sep 19 '22 02:09

Vision Coderz