Get file from multipart form

Hi,

I developed a simple single page with a form like this:

<form method="post" action="<?php echo $this->action('importExcel') ?>" enctype="multipart/form-data">
    <div class="form-group">
        <?= $form->label('excelFile', 'Fichier Excel') ?>
        <?= $form->file('excelFile') ?>
    </div>

    <div class="form-group">
        <?= $form->submit('submit', 'Importer'); ?>
    </div>
</form>

And I’d like to know how can I get the file content of excelFile from my importExcel function ? Found nothing relevant about this on the web. I didn’t try doing it using vanilla PHP because I think there is a better way ?

Hello. You can see exactly how to do it by checking the method action_upload in the Document library block’s controller blocks\document_library\controller.php

1 Like