coder72's avatar

How to retrive image in image preview in edit form ?

I am trying to use image preview before upload.Its working fine while creating new.but how to retrieve that image that has already saved in edit form and can be change when i try to change another image ? This is my input type for file.

 <input type="file" class="form-control" name="image" id="image">
      	<img id="user_image" src="{asset('admin/images/user/'.auth()->user()->image)}}" />

This is my script file to preview image before uploading

<script>

      function readURL(input) {


          if (input.files && input.files[0]) {

              var reader = new FileReader();
              reader.onload = function(e) {
                  @php  $value=auth()->user()->image; @endphp
                  $('#user_image').show();
                    $('#user_image').attr('src', e.target.result).slideDown();;
              };

              reader.readAsDataURL(input.files[0]);
          }
      }

      $("#image").change(function() {
          readURL(this);
      });
  </script>
0 likes
0 replies

Please or to participate in this conversation.