Skip to content

Instantly share code, notes, and snippets.

@tanyaharris
Last active November 18, 2018 08:28
Show Gist options
  • Save tanyaharris/9dc5684ca225f8a673b16d109b5934dc to your computer and use it in GitHub Desktop.
Save tanyaharris/9dc5684ca225f8a673b16d109b5934dc to your computer and use it in GitHub Desktop.

Создание формы загрузки файлов в Laravel

  • Добавить в тег form enctype="multipart/form-data"
 <form action="{{route('upload-image')}}" method="post"  enctype="multipart/form-data">
  • У тега input добавить name
<input name="image" type="file">

В контроллере проверяем с помощью $request->all()

Пример формы

<form action="{{route('upload-image')}}" method="post" class="m-3" enctype="multipart/form-data">
      {{ csrf_field() }}
      <label for="image">Image</label>
      <br>
      <input name="image" id="image" type="file">
      <br>
      <button class="btn btn-success mt-1" type="submit">Создать</button>
</form>

Готово, вы великолепны!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment