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

119
Views
how to change the image url when i paste the link

I work in javascript basically I want to show the image when the user pick the image from the device the image must change the code that I use in the javascript file is

function changeProfile(){

    var location = document.getElementById("profileLocation");
    alert(location.value);
    var image = document.getElementById("profileAAImage");
    image.src(location.value);
}

and the code that I wrote in html file is

<div class="row">
                                <div class="col-md-3 form-group" style="padding-left: 7%;">
                                    <img  id="profileImage" style="border-radius: 200px;" src="images/interne/areab%20suhaib.jpg" class="img-thumbnail" width="100" height="100" >
                                </div>
                                <div class="col-md-9 form-group mt-3 mt-md-0" style="padding-top: 5%;">
                                    <input  type="file" name="file"  class="form-control" id="profileLocation" onclick="changeProfile()" onkeyup="changeProfile()" placeholder="select profile image"
                                            required>
                                </div>
                            </div>

what I do to do the required task.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Change location.value to location.files[0] to get the selected file.

function changeProfile() {
  var location = document.getElementById("profileLocation");
  var image = document.getElementById("profileImage");
  image.src = window.URL.createObjectURL(location.files[0]);
}
<div class="row">
  <div class="col-md-3 form-group" style="padding-left: 7%;">
    <img id="profileImage" style="border-radius: 200px;" src="images/interne/areab%20suhaib.jpg" class="img-thumbnail" width="100" height="100">
  </div>
  <div class="col-md-9 form-group mt-3 mt-md-0" style="padding-top: 5%;">
    <input type="file" name="file" class="form-control" id="profileLocation" onchange="changeProfile()" placeholder="select profile image" required>
  </div>
</div>

about 4 years ago · Juan Pablo Isaza Report
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!