Closed paveltizek closed 7 years ago
You can save the uploaded file to temporary directory and save path or file name to session or move upload input to last step, other solution isn't.
For getting session: https://github.com/WebChemistry/wizard/blob/master/src/Wizard.php#L61
Thanks for reply, I can not move upload to last step. Now I am using your solution with temp directory but when I get back to upload step, it remove file. My code looks like this. Can you help me with it?
if (isset($this->values->image)) {
$imagePath = $this->values->image;
unset($this->values->image);
if ($imagePath->name) {
$wwwDir = $this->context->parameters['wwwDir'];
$dir = '/images/object/' . 'temp';
$filename = $imagePath->name;
$filepath = "$dir/$filename";
$imagePath->move($wwwDir . $filepath);
//save to session
}
}
`
In your step with upload input
public function stepX() {
$form->onSuccess[] = function ($form, $values) {
if ($values->image->isOk()) {
$path = ...; // save image
$this->getSection()->image = $path;
}
};
}
and in finish method
$path = $this->getSection()->image;
Thanks for help. I solved this with similiar solution.
When form contains upload input in a step other than last, file is not sent. Variable $_FILES is empty.