Yes you can, just make a name:
$name = 'pdf_font.' . $request->file->getClientOriginalExtension();
$request->file->storeAs('fonts', $name, 'public');
This should work.
I have files like this font.ttf I need to upload them
HTML code:
<form action="{{ route('admin.settings.pdf.update') }}" method="post" enctype="multipart/form-data">
@csrf
<input type="file" name="file" accept=".ttf" required>
<button type="submit" class="button green">upload</button>
</form>
Controller:
public function updatePdfFont(Request $request)
{
$request->validate([
'file' => 'required|file',
]);
// dd($request->all());
// rename($request->file, "pdf_font.ttf");
$request->file->store('fonts', 'public');
}
// public disk is a custom one that goes files to the public folder
The problem that I'm facing now when uploading font it uploaded with no extension like this wmRey4YaOLaldchlFV1l6GQylbZArc4xmyy2tXnL
The second thing I need is how can I rename the file before uploading it? like I want to rename the file to pdf_font.ttf
Yes you can, just make a name:
$name = 'pdf_font.' . $request->file->getClientOriginalExtension();
$request->file->storeAs('fonts', $name, 'public');
This should work.
Please or to participate in this conversation.