I have a project where in I have a form with a file...
How can I submit the form to a controller action without using the submit button just a plain button?
Asked
Active
Viewed 38 times
0

tereško
- 58,060
- 25
- 98
- 150

Ramppy Dumppy
- 2,667
- 7
- 27
- 37
-
http://stackoverflow.com/questions/166221/how-can-i-upload-files-asynchronously-with-jquery – Jatin patil Mar 19 '14 at 06:43
3 Answers
0
You have many options:
- Start uploading of file on selection of file event callback.
- Start uploading of file on click on a html element
- Upload the obvious way

prady00
- 721
- 1
- 6
- 17
0
You can use jQuery to achieve what you want. Here is the basics taken from here
<form id="target" action="destination.html">
<input type="text" value="Hello there">
<input type="submit" value="Go">
</form>
<div id="other">
Trigger the handler
</div>
In your jQuery:
$( "#other" ).click(function() {
//Do stuff, then submit
$( "#target" ).submit();
});

Akira Dawson
- 1,247
- 4
- 21
- 45
0
Try this (using plain javascript):
<form action="upload_file.php" method="post"
enctype="multipart/form-data" name="myForm">
<label for="file">Filename:</label>
<input type="file" name="file" id="file"><br>
<input type="button" name="button1" value="Just a Button" onclick="submitForm()">
</form>
<script type="text/javascript">
function submitForm() {
document.myForm.submit();
}
</script>

myusuf
- 11,810
- 11
- 35
- 50