HTML, JQuery, JavaScript - How to fill input file on page load

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

Upvotes: 0

Views: 2738

Answers (1)

Shridhar Sharma
Shridhar Sharma

Reputation: 2387

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.

Upvotes: 1

Related Questions