Created
June 10, 2019 11:24
-
-
Save Titoratus/05f51403123babbe030ffb23e26c02f9 to your computer and use it in GitHub Desktop.
[OctoberCMS] Загрузка файлов через Frontend для модели
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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