Answer the question
In order to leave comments, you need to log in
Can't upload file to Laravel 8?
I can't upload the file to the server, what's the problem?
Sending
if ($request->isMethod('post') && $request->file('file')) {
$file = $request->file('file');
$upload_folder = 'public/folder';
$filename = $file->getClientOriginalName(); //
Storage::putFileAs($upload_folder, $file, $filename);
}
return $request;
<form action="/ajax/add" method="POST" enctype="multipart/form-data" class="block-add-new-exercise">
@csrf
<div class="block">
<label>Имя задачи:</label>
<input name="name" type="text" placeholder="Введите значение">
</div>
<div class="block">
<label>Описание:</label>
<input name="description" type="text" placeholder="Введите значение">
</div>
<div class="block">
<label>До какой даты выполнить:</label>
<input name="date" type="date" placeholder="Введите значение">
</div>
<div class="block">
<label>Введите хэштеги (через запятую):</label>
<div name="hashtag" id="hashtags" type="text" placeholder="Введите значение" contenteditable="true"></div>
</div>
<div class="block">
<label>Укажите приоритет (от 1 до 10 - чем меньше тем приоритетние):</label>
<input name="priority" type="number" placeholder="Введите значение">
</div>
<div class="block" style="margin-bottom: 22px;">
<label>Прикрепить файл:</label>
<input name="file" type="file">
</div>
<div class="block">
<button type="submit" id="submit">Добавить</button>
<button id="cancel">Отмена</button>
</div>
</form>
{"_token":"hTTrrf6jTFeqUPHvFlhMUmgZtFWRHmcM5u7Ouo4m","name":"123","description":"123","date":"0132-03-12","priority":"12","file":{}}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question