Problems with memory when uploading a file by type input file

0

When uploading a file through a file type input, the file is an excel type, in which a table with different data must be filled, when it is uploaded to the server it gives me the following error

  

PHP Warning: POST Content-Length of 8978294 bytes exceeds the limit   of 8388608 bytes in Unknown on line 0

Change the values of

post-max-size (change 8M to 800M).
upload-max-filesize (change 2M to 2000M).

PS: use several values and none worked.

When I did, another error appeared:

  

Fatal error: Allowed memory size of 134217728 bytes exhausted (tried   to allocate 64 bytes)

Form in cakePHP:

<div class="btn boton btn-default btn-file col-md-7" style="padding-bottom: 4%;">
        <?php
            echo $this->Form->create(
               'Ordenmateriale',
                array(
                    'id' => 'formulario',
                    'class' => 'boton',
                    'type' => 'file'
                )
            );
        ?>
        <?php
            echo $this->Form->input(
                'archivo',
                array(
                    'type' => 'file',
                    'class' => 'boton',
                    'label'=>'  <i class="fa fa-paperclip"></i> <br>Migrar Datos :'
                )
            );
        ?>
    </div>
    <div class="col-md-12" style="margin-top: 2%;">
        <?php 
            echo $this->Form->submit(
                'Adjuntar Archivo',
                array(
                    'class' => 'btn btn-primary boton col-md-3 ',
                    'title' => 'Click Aqui para Adjuntar',
                    'onclick' => 'return validar();'
                )
            );
            echo $this->Form->end();
        ?>
    </div>
    
asked by R3d3r 82 31.12.2018 в 15:55
source

2 answers

0

First, you must increase the size of the variable upload_max_filesize = 1000M; post_max_size = 1000M; and memory_limit = 512M or higher in the php.ini file and then restart Apache (always , when making a configuration change you must restart it).

    
answered by 31.12.2018 в 16:40
0

To begin with I would like to see the form from where you upload your file as you should consider the name="MAX_FILE_SIZE" value=

On the other hand the PHP code must validate what was sent by the form. And the first message is just an alert that you can validate with $_FILES['fichero_usuario']['error']

How much does your Excel file weigh? and how do you plan to process it to fill your tables? Do you have the whole process clear?

    
answered by 01.01.2019 в 16:10