0

fill input file on load How, please help me

some code not work :

<input type="file" class="form-control" id="fup" value="" />
<script>
    window.onload = function () {
        document.getElementById('fup').value = "C:/AiOLog.txt";
    }
</script>

Image After code , nothing changed

Community
  • 1
  • 1

1 Answers1

1

You cannot set a value to an input[type=file] element, because its very dangerous for a user. If the browser allow to do this then everyone will be able to get the files from the system of the user of a website, which is totally irrelevant for a user's privacy.

Shridhar Sharma
  • 2,337
  • 1
  • 9
  • 13
  • It is possible to set the value of an input[type=file] using the contents of an other input[type=file] but it is not possible to set the value of an input[type=file] using a local file. – pitaridis Jan 09 '18 at 06:54
  • 1
    No, it;s not possible in any way to manipulate a `input[type=file]` data. You should you any other logic for the work you are trying to do – Shridhar Sharma Jan 09 '18 at 07:00
  • Shridhar you are right. I am sorry for the inaccurate comment. – pitaridis Jan 09 '18 at 07:34