Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Laravel Saving file posts it as a bin file

Am trying to save a file in laravel but it endsup being saved as a bin file

 $file = $request->file('file');
 $name = Carbon::now()->format('Y-m-d')."-".strtotime(Carbon::now()).".".$file->extension();
 $stored =$file-> storeAs('temporary', $name); //save the file to temporary 

Now the above saves every file as .bin file When i check

$file->extension();

Am getting .bin

Where am i going wrong?

like image 586
Geoff Avatar asked Jan 26 '26 12:01

Geoff


1 Answers

Use the getClientOriginalExtension() method instead of extension():

$file->getClientOriginalExtension();
like image 110
Alexey Mezenin Avatar answered Jan 29 '26 02:01

Alexey Mezenin