Reputation: 105
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.
Upvotes: 9
Views: 25827
Reputation: 2763
Another way you can do this, and you can specify the file_name
and the path
of your file. Is to use storeAs
so you will end-up with something like this
$file = $request->file('file');
// Generate a file name with extension
$fileName = 'profile-'.time().'.'.$file->getClientOriginalExtension();
// Save the file
$path = $file->storeAs('files', $fileName);
dd($path);
#output
"files/profile-1564586486.jpg"
Upvotes: 0
Reputation: 31
to make sure the location you can use the functions
ex:
File::put(public_path('uploads'), $data);
Upvotes: 3
Reputation: 8078
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
Upvotes: 7
Reputation: 17658
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
.
Upvotes: 8