0

I have a simple form

<form enctype="multipart/form-data" action="/clients" method="post">
    <input id="file" type="file" />
</form>

I need to invoke file upload dialog and if it was successful - send the form (using javascipt)

2
  • "and if it was successful, send the form" the file gets uploaded by sending the form, so what you are asking doesn't make any sense Commented Mar 2, 2014 at 2:24
  • firstly I need user to choose file on his computer. Commented Mar 2, 2014 at 3:07

1 Answer 1

1
<form enctype="multipart/form-data" action="/clients" method="post" id="fileForm">
    <input id="file" type="file" />
</form>

<script>
document.getElementById('file').onchange=function () {
document.getElementById('fileForm').submit();
}
</script>
Sign up to request clarification or add additional context in comments.

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.