1

I am implementing \kartik\file\FileInput widget.

Here is my code:

<?php
            echo FileInput::widget([
                'name' => 'dataSiswa',
                'options' => [
                    'multiple' => false
                ],
                'pluginOptions' => [
                    'uploadUrl' => Url::toRoute('pesertadidikuploadproses'),
                    'uploadExtraData' => ['folderId' => ""],
                    'showUpload' => true
                ],
                'pluginEvents' => [
                    'fileuploaded' => "function(event, data, previewId, index) {
                                            $('#pesan').show();
                                            $('#pesan').html(data.response.pesan);
                                        }"
                ]
            ]);
            ?>

I want the value of uploadExtraData should be get as serialize data form --> $('#formid').serialize();

Bob
  • 5,510
  • 9
  • 48
  • 80
Maulana Yusuf
  • 337
  • 2
  • 4
  • 16

1 Answers1

0

Like said in this post, you can't direct access to files on a user computer. One technique is to use and iframe to do the submission and that way you won't have to refresh the page. So use this plugin and just do something as below:

$(function() {
  $('#ifoftheform').ajaxForm(function(result) {
     alert('the form was successfully processed');
  });
});
Community
  • 1
  • 1
Luis Campos
  • 93
  • 1
  • 10