Solution 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.

Solution 2 :

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.");
}

Problem :

<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?

Comments

Comment posted by freefaller

Simple, you can’t… massive security risk otherwise

Comment posted by freefaller

I’m not sure why you’re suggesting something they didn’t ask for and you don’t even recommend?!

Comment posted by Volpe v2

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).

By

Leave a Reply

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