I need to upload a facebook-style image. The user clicks a button, selects the image and clicking OK in the Windows dialog, the image is sent automatically.
Ialreadyhavethefollowingcodes:
$('.trocar_foto').click(function(){
$('#img_config input[type=file]').trigger('click');
});
<form enctype="multipart/form-data">
<input type="file" name="trocar_foto" style="display:none"/>
<button class="trocar_foto" type="submit">Alterar foto</button>
</form>