I currently have a form that lets a user select an image. After the image has been selected they need to click the submit button. I’m using jquery so the call ends up looking like this:
$('#image_form').ajaxForm(function(data) {
// do some stuff
});
here is the HTML:
<form id="image_form" enctype="multipart/form-data" action="load_photo.php" method="post" >
<input type="hidden" name="MAX_FILE_SIZE" value="8000000" />
<table>
<tr>
<td>
<label for="mapimage">Select an image:</label>
</td>
</tr>
<tr>
<td>
<input name="file" type="file" id="file"/>
</td>
</tr>
<tr>
<td>
<input type="submit" value="Update" name="update_photo" id="update_photo"/>
</td>
</tr>
</table>
</form>
Is it possible to trigger this form action after a user has browsed to a photo and selected it? Ideally they would not have to click the submit button.
When a file has been selected, the
changeevent fires on theinput[type=file]element, so just listen for that.