=
if($images !== null) {
$images_array=[];
foreach ($images as $image) {
$data=ImageUpload::instance()->uploadImage($image,'aboutpage');
array_push($images_array,$data);
}
$input['image']=json_encode($images_array);
}
if($b_images !== null) {
$input['banner_two_image']=ImageUpload::instance()->uploadImage($b_images,'aboutpage');
}
$images = $request->file('image');
<?php
namespace App\Helpers;
use Illuminate\Support\Facades\Storage;
class ImageUpload
{
public function uploadImage($requested_image,$location)
{
$storage_dir = 'images/'.$location;
$storage_path = Storage::disk('public')->path($storage_dir);
$filename = time() . '_banner_' . str_replace(' ', '-', strtolower($requested_image->getClientOriginalName()));
$requested_image->move($storage_path, $filename);
$storage_path = 'storage/' . $storage_dir . '/' . $filename;
return $storage_path;
}
public static function instance()
{
return new ImageUpload();
}
}
<div class="form-group"><strong>image:</strong>{!! Form::file('image[]', array('multiple'=>true,'accept'=>'image/png, image/gif, image/jpeg','value'=>'{{$data->image}}','placeholder' => 'image','class' => 'form-control')) !!}</div>
@foreach (json_decode($data->image) as $image)
<img style="width:100px;height:100px;" src="{{asset($image)}}" alt="11.jpg">
@endforeach
<div class="form-group"><strong>banner_image:</strong>{!! Form::file('banner_image', array('value'=>'{{$data->banner_image}}', 'accept'=>'image/png, image/gif, image/jpeg','placeholder' => 'banner_two_image','class' => 'form-control')) !!}</div>
<img style="width:100px;height:100px;" src="{{asset($data->banner_image)}}" alt="11.jpg">
=
No comments:
Post a Comment