Sending an attachment via jquery ("input 'file'" always empty)
Hello everyone, I have an e-mail form that I use for my small projects. It works normally!
I recently had to add a field for the visitor to send an attached file.
When submitting the form all the filled fields are sent, except for the "input file".
PS: Validation of fields occurs normally. Only when sending the form all the data arrives until the "send-proof.php" via "POST", less the field "proof".
Can someone help me solve this problem with my code?
- <script type="text/javascript">
- $(function(){
- // COMPROVANTE
- // ====================================
- $( "#proof-form" ).validate( {
- rules: {
- nome: {
- required: true,
- minlength: 3
- },
- seuemail: {
- required: true,
- email: true
- },
- seuwhatsapp: {
- required: false,
- minlength: 16
- },
- codigopedido: {
- required: true
- },
- proof: {
- required: true,
- accept: "application/pdf,image/jpg,image/jpeg,image/png"
- },
- t_data: {
- required: true,
- minlength: 10
- },
- t_hora: {
- required: true,
- minlength: 8
- },
- n_doc: {
- required: true
- },
- suamensagem: {
- required: true,
- minlength: 20
- }
- },
- errorElement: "span",
- errorClass: "help-inline-error",
- submitHandler: function(form){
- var dados = $(form).serialize();
- $.ajax({
- type: "POST",
- url: "send-proof.php",
- data: dados,
- success: function(data)
- {
- $('#result').html(data);
- }
- });
- setTimeout(function() {
- $('#alert').fadeOut('slow');}, 3000);
- return false;
- }
- });
- });
- </script>
--
Atenciosamente
Juscelino Barão