0
<input id="inputype" type="file" accept="image/*" value="../Images/whatever.gif">

also can i change the value by calling a function?

this function will be invoked onclick.

function click() {
   document.getElementById('inputype').value = "../Images/whatever.gif";  
}

how do i get this to work?

hannon qaoud
  • 79
  • 1
  • 12

2 Answers2

1

There is no default value in such a form element (imagine the security implications...).

If empty, it usually shows a label like:"Select a file to upload...".

If you want to have a plaecholder at all costs, you can fake it (like placing a div above the imput, and changing the appereance to look like one). I do not raccomand this approch.

Volpe v2
  • 78
  • 7
  • I'm not sure why you're suggesting something they didn't ask for and you don't even recommend?! – freefaller Jan 28 '20 at 16:35
  • That is the third option, for a more complete answer. I'm simply pointing out that making a fake loading imput is always possible, therfore is also possible to make a default (that does not work, so it can't load files). – Volpe v2 Jan 28 '20 at 16:52
0

To check for empty value for an input with type file:

if (document.getElementById("inputype").files.length === 0) {
  console.log("You have not selected a file yet.");
}