user image

Great Coder
Published in : 2022-02-11

Coping plain text into form bug.


I wrote the following code and use it to copy and submit types of data into a form.

In fact I used to use this small peace of code in the past to copy just images as the browsers abilities were limited, but now they have allowed this to all types of data including texts too.

The problem here is that the code thinks that the text is a file when copies and goes directly to submit.

How to fix that?


let fileInput = document.getElementById("doc_attachment");

window.addEventListener('paste', e => {
  fileInput.files = e.clipboardData.files;


nico Date : 2022-02-19

Best answers


Best answers


Hello did you try the following to get the data ?



Leave a comment

Join us

Join our community and get the chance to solve your code issues & share your opinion with us

Sign up Now

Related posts

Adding an id number at the first index to an array of objects
Publish date: 2022-02-13 | Comments: 1

Tag: Javascript

JAVASCRIPT: How do I add another key to object?
Publish date: 2022-03-06 | Comments: 3

Tag: Javascript

Check if div have touch another div
Publish date: 2022-03-02 | Comments: 1

Tag: Javascript

Help: How do I loop simple JSON objects to iterate all keys and values itself?
Publish date: 2022-03-06 | Comments: 1

Tag: Javascript

How to move a div with its content to TinyMEC editor?
Publish date: 2022-02-11 | Comments: 0

Tag: Javascript

Can we add a javascript or jQuery to the URL?
Publish date: 2022-03-05 | Comments: 2

Tag: Javascript

Can I read a local json, image or text file from Javascript?
Publish date: 2022-03-03 | Comments: 1

Tag: Javascript