【发布时间】:2021-09-01 10:25:16
【问题描述】:
我想使用 Laravel 在数据库中保存多张图片。我在 public_path() 中出现错误提示
(消息:“找不到类 'Gallerie_img_client'”)
这是我的代码:
public static function uploadImage(Request $request, $user)
{
DB::beginTransaction();
try {
$current_timestamp = Carbon::now()->timestamp; // Produces something like 1552296328
$emitter = User::where('id', $user)->where('active', true)->first();
$haseFile = $request->input('hasFile');
$idClient = $request->input('idClient');
if ($haseFile) {
foreach ($request->input('files') as $key => $file) {
$aa = explode(';', $file['file']);
$aa1 = explode('/', $aa[0]);
$extension = $aa1[1];
$fileName = $current_timestamp . $key . '.' . $extension;
if (strpos($file['file'], ',') !== false) {
@list($encode, $file['file']) = explode(',', $file['file']);
}
Gallerie_img_client::insert([
// 'id'=> '1',
'name'=>$file['name'],
'url'=>$fileName,
'size'=>$file['size'],
'idClient'=>$idClient,
]);
/*** Save file in folder public/data/Images ***/
\Gallerie_img_client::put(public_path() . '/data' . '/' . '/Images' . '/' . == >causing me error
$fileName, base64_decode($file['file']));
// Storage::put($fileName, $file);
}
}
【问题讨论】:
-
问题在于您正在使用的类 Gallerie_img_client 尝试导入它
-
我做到了!但它在这一行中不起作用“\Gallerie_img_client::put(public_path() . '/data' ...”
-
您是否尝试过像这样导入它:使用 path/to/Gallerie_img_client; ?
-
尝试删除行中的斜线
-
@HananAlhasan 我收到了这个错误(未定义的方法 App\Gallerie_img_client::put())