-3
Just create a listener to run some code when the input
is clicked and that will open the window to select a file:
$("#file").on("click", function(){
alert("vai abrir a janela de selecionar arquivo");
// insira aqui o código que deseja executar
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<input type="file" id="file" />
But this will work even if he does not choose any file, just clicking to select the file, will already trigger the event. What if the user clicks cancel and does not select anything? He wants the action to fire only after clicking open, then the
value
countryinput
would no longer be empty, and could indicate that the file was selected, and also a check to see if it was changed and trigger another event. For me this answer does not answer the question of AP.– Raizant
His question is almost the same as Soen’s How to determine if user Selected a file for file upload?
– Raizant