This forum has moved to a new location and is in read-only mode. Please visit talk.octobercms.com to access the new location.
butching
ive been trying to upload a file using pop up and i cant figure it out.
model
public $attachOne = [
'input_file' => ['System\Models\File', 'public' => false]
];
the anchor to trigger popup
<a href="#"
data-control="popup"
data-handler="onUploadForm"
data-request-data="upload_mode: 1"
class="btn btn-primary oc-icon-plus">
New Upload</a>
controller
public function onUploadForm() //pop up
{
$this->asExtension('FormController')->create();
return $this->makePartial('upload_form');
}
public function onUpload()
{
return $this->asExtension('FormController')->create_onSave();
}
config_form.yaml.
fields:
input_file:
label:
type: fileupload
mode: file
fileTypes: ['txt', 'csv']
mimeTypes: 'txt,csv'
span: auto
upload_form.html
<?= Form::open(['id' => 'uploadForm', 'files' => true, 'data-request' => "onUpload"]) ?>
<input type="hidden" name="upload_mode" value="1" />
<div class="modal-body">
<?= $this->formRender() ?>
</div>
<div class="modal-footer">
<button
type="submit"
data-request-data="redirect:1"
data-hotkey="ctrl+s, cmd+s"
data-popup-load-indicator
class="btn btn-primary">
Upload File
</button>
</div>
<?= Form::close() ?>
everytime i upload something.. its not being saved in the system file table. am i missing something to make the popup/ajax work using file upload?
thanks
adc_91
I have found the solution.
https://github.com/octobercms/october/issues/2852#issuecomment-301292260
1-3 of 3