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

256
Views
Unable to get a selected image src to get copied to a file input refs

I have been on this for a full day and I just cannot find an answer to it.

Imagine a form with an upload file input field. Next to it there is also a button called "select template". The user can either upload his own image or select an image from a given template.

Here is the problem, I am unable to send the selected image to the input field(so I can process it in my axios post later on).

This is the table where all the template files are showing up:

<table class="table table-borderless table-hover">
<thead>
<tr>
<th></th>
<th></th>
<th></th>
</tr>
</thead>
<tbody>
<tr v-for="item in image_gallery">
<td class="align-middle">{{ item.id }}</td>
<td class="align-middle">{{ item.title }}</td>
<td><img :src="'/storage/images/' + item_image" class="img-thumbnail" alt="" style="width: 75px;" @click="selectImage(item.id, $event)">
</td>
</tr>
</tbody>
</table>

When the user clicks on the above image, I would like the file to be set to this input field(which is the same input where the user can upload his own file).

<label class="btn btn-info btn-block btn-sm">
<i class="fas fa-upload text-white"></i>
<input
type="file"
id="file"
@change="onFileAttached(1)"
ref="file"
accept="image/png, image/jpeg"
hidden/>
</label>

I tried this:

selectImage(id, event){

this.$refs.files[0].src = event.files[0].src;
//or
this.$refs.files[0].src = event.target.src;
}

But no luck.....I am not understanding what I am missing :-(

Is there a way to manually take a URL from a given image to set this image to an input field?

Thanks in advance for guiding me a bit.

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!