Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

116
Views
Javascript show image src with it's file extension

Hello everyone I used javascript to preview my image before it saves in my database which works perfectly but I want it to show not as blob:url... but I was the image src to also carry the file extension please is there anyway i can make this to work?

Here's my code

<div class="form-group">
       <div class="n_listed" style="margin-top: -10px">
            <br>
          <label for="file" style="cursor: pointer;">
             <a>
             <i class="mdi mdi-plus-box-outline"></i>
             Upload Image </a> &nbsp; &nbsp;
             &nbsp; &nbsp;</label><br>
               <input type="file" class="form-control @error('banner_image') is-invalid @enderror"  accept="image/*" name="banner_image" id="file"  onchange="loadFile(event)">
                @error('banner_image')
                 <span class="invalid-feedback" role="alert">
                  <strong>{{ $message }}</strong>
                 </span>
                 @enderror
               <p><img id="cover" style="max-width: 750px;" src="{{asset('dasharea/img/placeholder.png')}}"/></p>
               <div style="color: #333;font-size: .9em;margin: 10px 0 5px" class="progress_msg">
                      Note: Maximum size of the image should be 10MB
                </div>
                <script>
                  var loadFile = function(event) {
                  // let imgfile = $('#file').val();
                  // var imgext = imgfile.split('.').pop();
                     var image = document.getElementById('cover');
                     image.src = URL.createObjectURL(event.target.files[0]);
                       };
                   </script>
                                                                                                    
                    </div>
                  </div>

Please I really need help on this. I want it to save as blob:http://localhost:8000/6e315126-ef45-4419-a35d-c3dd2eb2eff7.jpg or .png or depending on the file extension instead of just blob:http://localhost:8000/6e315126-ef45-4419-a35d-c3dd2eb2eff7. Because based on validation rules the image cannot save in the database without it's file extension.

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!