I'm creating a CRUD project with file uploads using json_encode for uploading the file to a database. How do I show the file that I've uploaded from the blade view? Is it possible to delete it from the view?
$sid = Sid::find($id);
$data = [];
if($request->file('file_uploads'))
{
foreach($request->file('file_uploads') as $file)
{
$name = $file->getClientOriginalName();
$path = 'public/file/'.$sid->employee_name;
$file->move($path, $name);
$data[] = $name;
}
}
$sid->employee_sid = $request->employee_sid;
$sid->employee_npk = $request->employee_npk;
$sid->employee_name = $request->employee_name;
$sid->file_uploads = count($data)? json_encode(array_merge(json_decode($sid->file_uploads, true),$data)): $sid->file_uploads;
$sid->save();
I want to show the file/image that I uploaded before in the blade view and to know if it is possible to delete it from view-blade.
This is my upload files from the edit form.
<div class="col-md-12">
<div class="row">
<div class="col-md-4">
<div class="form-group">
<label for="UploadFileSertifUnit">Upload Sertifikat Unit</label>
<input type="file" id="UploadFileSertifUnit" name="file_uploads[]" multiple>
<p>Ukuran Max : 2 MB</p>
</div>
</div>
</div>
</div>
I want to show the file above this code.