After a lot of searches i found the trouble but i have no idea how to fix it.
When i set the form to enctype="multipart/form-data"
the CakePHP2 send an empty $_POST
, the same case print $this->request->data
. If i remove the add() method works as well.
It occurred after migrating from Windows to Debian, but i've checked permissions and edited php.ini (POST_MAX_SIZE and UPLOAD) and seems perfect.
add()
code
if ($this->request->is('post')) {
$this->Request->create();
if ($this->Request->save($this->request->data)) {
$this->Flash->success(__('A solicitação foi enviada com sucesso'));
return $this->redirect(array('action' => 'index'));
} else {
$this->Flash->error(__('The request could not be saved. Please, try again.'));
//print_r($this->Request->validationErrors);
Front-end
<div class="requests form">
<?php echo $this->Form->create('Request', array('type' => 'file')); ?>
<fieldset>
<legend><?php echo __('Enviar solicitação'); ?></legend>
<?php
echo $this->Form->input('user_id', array('hidden', 'label' => false, 'value' => AuthComponent::user('id')));
echo $this->Form->input('hash', array('hidden', 'label' => false, 'value' => md5(uniqid(rand(), true))));
echo $this->Form->input('email', array('label' => 'E-mail'));
echo $this->Form->input('fullname', array('label' => 'Nome completo'));
echo $this->Form->input('city_id', array('label' => 'Cidade'));
//echo $this->Form->input('contract', array('label' => 'Contrato', 'type' => 'file', 'accept' => 'application/pdf'));
echo $this->Form->file('contract');
?>
</fieldset>
<?php echo $this->Form->end(__('Solicitar')); ?>
</div>
debug output
/app/Controller/RequestsController.php (line 77)
array()
note: i've removed the file upload block, i figured out is useless