0

I am attempting to add a file/image upload form to my site, and I am getting the following error

Unexpected field 'uploadfile' in POST data, Missing field 'uploadfile.name, uploadfile.type, uploadfile.tmp_name, uploadfile.error, uploadfile.size' in POST data

from the following form code

<?= $this->Form->create(null, ['id' => 'save_upload_image', 'url' => "/research_station/save_upload_image", 'class' => 'upload-file']) ?>

    <div class="form-group">
        <?= $this->Form->control('uploadname', ['id' => 'uploadname']) ?>
    </div>

    <div class="form-group">
        <?= $this->Form->file('uploadfile', array('name' => 'uploadfile', 'type' => 'file')) ?>
    </div>

    <?= $this->Form->button('Upload', ['class' => 'btn btn-success btn-pill pull-right']) ?>

<?= $this->Form->end() ?>

Any ideas on what I am doing wrong?

Jeffrey L. Roberts
  • 2,844
  • 5
  • 34
  • 69
  • Looks very much like something to do with the Security component (or middleware, depending on which you're using). – Greg Schmidt Mar 16 '19 at 05:45
  • 2
    The form must be [**set to `'type' => 'file'`**](https://book.cakephp.org/3.0/en/views/helpers/form.html#changing-the-http-method-for-a-form) too. – ndm Mar 16 '19 at 12:54

0 Answers0