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

2
  • 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 Commented Dec 6, 2012 at 9:21
  • 1
    My guess is that you want a styled file input. If that's the case, see here: stackoverflow.com/questions/3226167/… Commented Dec 6, 2012 at 9:25

2 Answers 2

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());
});
Sign up to request clarification or add additional context in comments.

Comments

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?

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.