Skip to main content
1 de 3
user avatar
user avatar

Sem form e sem botão submit

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<input id='ads-files-edit' type='file' accept='image/*' placeholder='Selecione a imagem' data-max-size='5242880' class='form-control form-group-lg ads-files-edit'>

<script language="javascript">
<!--
$(document).ready(function() {
    $('#ads-files-edit').change(function(){
        var file_data = $('#ads-files-edit').prop('files')[0];   
        var form_data = new FormData();                  
        form_data.append('file', file_data);
        $.ajax({
            url: "enviar-imagem.php",
            type: "POST",
            data: form_data,
            contentType: false,
            cache: false,
            processData:false,
            success: function(data){
                alert(data);
            }
        });
    });
})
//-->
</script>
user60252