Closed toproplus closed 1 year ago
You're right, the file can't be session-stored between steps without saving/storing on the server/s3/etc, because Serialization of 'Illuminate\Http\UploadedFile' is not allowed
(that's if you try to do return $this->next($request->all());
from file-uploading StepForm@handle).
The only way to accomplish something like that is to store file on one step, and use its path on another, as you rightfully suggested. StepForm with file upload:
class Upload extends \Encore\Admin\Widgets\StepForm {
public $title = 'Upload step';
public function handle(\Illuminate\Http\Request $request) {
$res['myfile'] = $request->file('myfile')->store('temp');
return $this->next($res);
}
public function form() {
$this->image('myfile'); // used image here, will be similar with `file`
}
}
The any next StepForm that needs to use saved/stored file:
class Details extends \Encore\Admin\Widgets\StepForm {
public $title = 'Details step';
public function form() {
$this->text('name');
// use that session-stored data from "Upload" step in `form`, `handle`, etc.
$this->html('<img src="/storage/'. $this->all()['upload']['myfile'] . '" />');
}
}
That should work just ok. Let me know if you have something else in mind. But I'm still afraid you are obligated to store file between steps, I see no other way around.
Thanks for your answer, I'm got it . Good Luck to you !
Description:
在步骤表单的步骤一上传单图或多图,请问如何保存临时上传的文件对象到步骤二使用? 而
$this->next($data = []);
只能保存数组的字符串值,难道要先上传后拿到上传地址再跳步骤二?