Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save Titoratus/05f51403123babbe030ffb23e26c02f9 to your computer and use it in GitHub Desktop.
Save Titoratus/05f51403123babbe030ffb23e26c02f9 to your computer and use it in GitHub Desktop.
[OctoberCMS] Загрузка файлов через Frontend для модели
function onSubmit()
{
// get all post data
$data = post();
$form = YourModel::make($data);
// set specific field as we need
$form->form_files = Input::file('form_files');
$form->save();
// Note:
// $data = post();
// $data['form_files'] = Input::file('form_files'); <-- this won't work!
// YourModel::create($data);
}
==
<form data-request="onSubmit" data-request-files>
<input type="file" name="form_files">
<input type="submit>
</form>
If you need to upload multiple files add this attribute to the form: enctype='multipart/form-data' and multiple to the file input.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment