I have an array of files that being sent from request and the form element is also “enctype=”multipart/form-data” also product_logo[]
is the one that handles the file.
The issue is that when I try to loop inside the product logo. When I try to debug the $file it returns empty or when I also use hasFile()
function it returns false.
<code>
// Loop through product_logo
foreach ($validated['product_logo'] as $key => $value) {
dd($value, $validated['product_logo'], $request->hasFile($value));
$file = $request->file($value);
$path = $file->store('wl/product_logo', 'public');
$wlConfigImage = WlConfigImage::create([
'wl_config_id' => WlConfig::where('user_id', Auth::user()->id)->first()->id,
'name' => $value->getClientOriginalName(),
'path' => $path,
]);
WlService::where('user_id', Auth::user()->id)
->where('accelerate_service_id', $key)
->update([
'wl_config_images_id' => $wlConfigImage->id
]);
}
</code>
<code>
// Loop through product_logo
foreach ($validated['product_logo'] as $key => $value) {
dd($value, $validated['product_logo'], $request->hasFile($value));
$file = $request->file($value);
$path = $file->store('wl/product_logo', 'public');
$wlConfigImage = WlConfigImage::create([
'wl_config_id' => WlConfig::where('user_id', Auth::user()->id)->first()->id,
'name' => $value->getClientOriginalName(),
'path' => $path,
]);
WlService::where('user_id', Auth::user()->id)
->where('accelerate_service_id', $key)
->update([
'wl_config_images_id' => $wlConfigImage->id
]);
}
</code>
// Loop through product_logo
foreach ($validated['product_logo'] as $key => $value) {
dd($value, $validated['product_logo'], $request->hasFile($value));
$file = $request->file($value);
$path = $file->store('wl/product_logo', 'public');
$wlConfigImage = WlConfigImage::create([
'wl_config_id' => WlConfig::where('user_id', Auth::user()->id)->first()->id,
'name' => $value->getClientOriginalName(),
'path' => $path,
]);
WlService::where('user_id', Auth::user()->id)
->where('accelerate_service_id', $key)
->update([
'wl_config_images_id' => $wlConfigImage->id
]);
}
Debugging result