I allow my users to import local and remote files, but how can I use a single input to handle both cases ?
Like Stackoverflow, I can do it using tabs :

Or use radio buttons like :
<style>
.displayNone {
display:none;
}
</style>
<form action="test.php">
File type:
<input id="radio-url" name="type" type="radio" checked value="url" /> URL
<input id="radio-file" name="type" type="radio" value="file" /> File
<div id="url">
<input name="url" type="text" />
</div>
<div id="file" class="displayNone">
<input name="file" type="file" />
</div>
<input type="submit" value="Send" />
</form>
<script type="text/javascript">
$('#radio-url').click(function() {
$('#url').removeClass('displayNone');
$('#file').addClass('displayNone');
});
$('#radio-file').click(function() {
$('#file').removeClass('displayNone');
$('#url').addClass('displayNone');
});
</script>
Gives a switchable :

But how can I create such a field :

Note for the whole question that the way of handling file on the remote host isn’t important.
I found a working way using CSS :
Gives an editable
input type="text"above theinput type="file":But I think this will be tricky because browsers layout and behaviour is different for the
input type="file".