Answers for "laravel load image to div on image selected via input file"

PHP
0

laravel load image to div on image selected via input file

<html lang="en">
<head>
    <title>Change image on select new image from file input</title>
    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.js"></script>
</head>
<body>


<input type="file" name="file" id="profile-img">
<img src="" id="profile-img-tag" width="200px" />


<script type="text/javascript">
    function readURL(input) {
        if (input.files && input.files[0]) {
            var reader = new FileReader();
            
            reader.onload = function (e) {
                $('#profile-img-tag').attr('src', e.target.result);
            }
            reader.readAsDataURL(input.files[0]);
        }
    }
    $("#profile-img").change(function(){
        readURL(this);
    });
</script>


</body>
Posted by: Guest on July-31-2020

Code answers related to "laravel load image to div on image selected via input file"

Browse Popular Code Answers by Language