1

I want to write a program using simple html input type="text" and a button which will does the functionality of input type="file".

Cerbrus
  • 70,800
  • 18
  • 132
  • 147
  • You can make the file input hidden and make the button trigger the file's onclick. It works, but it is a lot of effort – Leandro Barreto Dec 06 '12 at 09:21
  • 1
    My guess is that you want a styled file input. If that's the case, see here: http://stackoverflow.com/questions/3226167/how-to-style-input-file-with-css3-javascript – Madara's Ghost Dec 06 '12 at 09:25

2 Answers2

1

HTML From :

<input type="file" class="file">
<input type="text" name="file" class="sfile">
<input type="submit" value="send file" name="submit">

css :

.file{
    visibility:hidden; # don't use display:none; because IE compability in js
}

jQuery :

$('.sfile').click(function(){
   $('.file').click();
});
$('.file').change(function(){
  $('.sfile').val($(this).val());
});
M Rostami
  • 4,035
  • 1
  • 35
  • 39
0

theoretically you could hack it (set 0 opacity to input[file] etc.) but manually typing the path to the text field will not work (will not send a file with the form). It seems a lot of unnecessary hacking. For what reason?

Dziad Borowy
  • 12,368
  • 4
  • 41
  • 53