"Internal Server Error" after newEntity()
Fluit opened this issue · 0 comments
Fluit commented
CakePHP: 4.1
cakephp-upload: 5.0.0 RC
in FotoTable I use
$this->addBehavior('Josegonzalez/Upload.Upload', [ 'foto' => [] ]);
and $validator->setProvider('upload', \Josegonzalez\Upload\Validation\DefaultValidation::class);
in defaultValidator-function.
Foto is associated with Machines
In the form:
$this->Form->create($machine, [
'type' => 'file',
'url' => [
'controller' => 'machines',
'action' => 'edit_foto_ter',
$result->id
]
]);
$this->Form->input('foto.omschrijving', ['value' => $result->type_machine]);
$this->Form->input('foto.foto', ['type' => 'file']);
$this->Form->button(__('Upload file to server'), ['type' => 'submit', 'confirm' => 'Confirm', 'class' => 'btn-info upload_button']);
$this->Form->end();
In MachinesController:
$data = $this->getRequest()->getData();
$foto = $this->Machines->Foto->newEntity($data['foto']);
A this point I get an internal server error and no file is uploaded.
debugging $data:
[
'foto' => [
'omschrijving' => 'METABO WE26-230 MVT Quick',
'foto' => object(Laminas\Diactoros\UploadedFile) id:0 {
private clientFilename => 'all about that bass.jpg'
private clientMediaType => 'image/jpeg'
private error => (int) 0
private file => 'C:\xampp\tmp\php3389.tmp'
private moved => false
private size => (int) 66145
private stream => null
},
],
]
The simular code works well with cakePHP 3.8.
any suggestions?