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

173
Views
Copy and paste files in Firefox with javascript

Good morning. I am trying to copy a file to a page that receives it, this works fine in chrome, edge and opera, but not in firefox....

The idea is to copy one or several files and to be able to paste them in the browser, the function below recognizes the paste effect, consults the clipboardData and inserts these images or videos in some input files.

The only browser that is not supported is Firefox, and version 83 of chrome as far as I have tested.

window.addEventListener("paste",copyPasteFunction); 

function copyPasteFunction(e){
        var fileInput = document.querySelector("input");
        if(e.clipboardData.files.length > 0){
            fileInput.files = e.clipboardData.files;
            $("input").eq(0).trigger("change");        
        }else{            
            console.log("%cFirefox or unsupported browser", "color:red");
        }
  }
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<input type="file">

¿Does anyone know of any other method to copy a file, paste it into a page and have it read and inserted into an input?

Thank you very much!

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!