public function update(Request $request, $id)
{
$siapakami = Weboption::findOrFail($id);
$value = implode(',',$request->value);
$siapakami->update([
'value'=> $value
]);
if ($request->hasFile('value')) {
$fileName = time() . '.' . $request->value->getClientOriginalName();
$validated['value'] = $fileName;
// move file
$request->picture->move(public_path('image/siapakami'), $fileName);
$old_foto = public_path("image/siapakami/{$value[1]}");
if (File::exists($old_foto)) {
File::delete($old_foto);
}
}
return redirect()->route('siapakami.index')->with('success', 'Berhasil merubah data');
}
Edit by @tomhatzer: Updated formatting.
Hi @dimaswicaksono917 👋
Did you add the part enctype="multipart/form-data"
to your <form>
tag like this?
<form enctype="multipart/form-data" action=...>`
The default is enctype="application/x-www-form-urlencoded"
which will not work nicely in combination with file uploads.
Have a great day!
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community