Set file required when edit image In Laravel?

  laravel, laravel-blade, php, upload

I have form to edit/upload image in Laravel Project.

<form action="{{ route('picture.update',$animal->sid) }}" enctype="multipart/form-data" method="POST">
 <div class="form-group">
                    <label class="form_group_title">Image</label>
                    <img id="file-image" src="{{asset('/images')}}/{{$animal->image}}" alt="Preview"
                        class="hidden img-thumbnail">
                    <input id="file-upload" type="file" name="image_upload" accept="image/*" class="hidden"
                    <label for="file-upload" id="file-drag">
                        <span class="btn btn-light">Select</span>
                    <div id="start">
                        <i class="fa fa-download" aria-hidden="true"></i>
                        <span class="text-danger">{{ $errors->first('image_upload') }}</span>
        function readURL(input, id) {
            id = id || '#file-image';
            if (input.files && input.files[0]) {
                var reader = new FileReader();

                reader.onload = function(e) {


The required is descried below:

        'name' => 'required',
        'name_en' => 'required',
        'image_upload' => 'required|image|mimes:jpeg,png,jpg,gif,svg|max:500000',
        'date'  => 'required',

How to set the default upload image if I don’t upload by reading image from database?

Source: Laravel StackOverflow

Leave a Reply