Specifying a specific file from a URL to assign to a File type in JavaScript


We have:

<input type="file" onchange="showFile(this)">

<script>
function showFile(input) {
  let file = input.files[0];

  alert(`File name: ${file.name}`);
  alert(`Last modified: ${file.lastModified}`);
}
</script>

Is it possible to set file with a local or file from a URL? I tried new File() but that did not read the file in question.

Source: JavaSript – Stack Overflow

November 23, 2021
Category : News
Tags: file | input | javascript

Leave a Reply

Your email address will not be published. Required fields are marked *

Sitemap | Terms | Privacy | Cookies | Advertising

Senior Software Developer

Creator of @LzoMedia I am a backend software developer based in London who likes beautiful code and has an adherence to standards & love's open-source.