0
我試圖用laravel中的隊列(bean)上傳文件,但是我得到這個錯誤:'Illuminate \ Http \ UploadedFile'的序列化是不允許Laravel隊列錯誤'Illuminate Http UploadedFile'的序列化是不允許的
我的代碼是:
protected $file;
protected $Id;
public function __construct($file,$Id)
{
$this->file = $file
$this->Id = $Id;
}
public function handle()
{
$qFile = $this->file;
$qId = $this->Id;
$s3 = Storage::disk('s3');
$extension = $qFile->guessExtension();
$filename = uniqid().'.'.$extension;
//Create and resize images
$image = Image::make($qFile)->resize(null, 600, function ($constraint) {
$constraint->aspectRatio();
});
$image->encode($extension);
$imageLarge = Image::make($qFile)->resize(null, 800, function ($constraint) {
$constraint->aspectRatio();
});
$imageLarge->encode($extension);
// upload image to S3
$s3->put("images/{$qId}/main/".$filename, (string) $image, 'public');
$s3->put("images/{$qId}/large/".$filename, (string) $imageLarge, 'public');
// make image entry to DB
File::create([
'a_f_id' => $qId,
'file_name' => $filename,
]);
}
但如果我刪除:
保護$文件; 保護$ Id;
我不明白的錯誤
您是否嘗試將'protected $ file'更改爲'private $ file'? –