【发布时间】:2019-11-10 21:51:12
【问题描述】:
我是 laravel 新手,尝试加密上传的文件。这是我的控制器:
if ($file != null && !empty($file))
{
$userfile = DNEUser::find($lastUserId);
$user_store_pic = $request->file('user_store_pic');
$fileContent = $user_store_pic->get();
$encryptedContent = encrypt($fileContent);
$s3 = \Storage::disk('uploads');
//$array=explode(" ",$encryptedContent);
$user_store_pic_name = $lastUserId.'_'.time().'.' .$encryptedContent->getClientOriginalExtension();
$filePath = 'store/'.$user_store_pic_name;
$s3->put($filePath, file_get_contents($encryptedContent));
$userStorePicName = $filePath;
$userfile->user_store_pic = $userStorePicName;
$userfile->save();
}
我正在尝试按照https://stefanzweifel.io/posts/how-to-encrypt-file-uploads-with-laravel/ 加密文件
但我在提交表单时遇到错误:
"ymfony\Component\Debug\Exception\FatalThrowableError (E_ERROR) 调用成员函数 getClientOriginalExtension() on 字符串”
我尝试使用explode转换为数组,但它显示数组的相同错误:
“调用数组上的成员函数getClientOriginalExtension()”
【问题讨论】:
标签: laravel encryption laravel-encryption