Jump to content

POWERED BY:

belann

jquery submissão de arquivo para o php

Recommended Posts

Olá!

 

Tenho um código em jquery ajax que na hora do php receber recebe o $_POST vazio.

segue código abaixo.

 

$("#fblog").submit(function(event){
      var property = document.getElementById('file');  
      var str = new FormData();
       
    var dados =  $("#fblog").serialize();
    str.append('file', property.files[0]);
    
    
      
    event.preventDefault();
    $.ajax({
      url : "incluir.php", 
      type : 'POST',
      contentType: false,     
      cache: false,
      processData: false, 
      data : {dados, str},  
      beforeSend:function(){
                   $('#msgfim').html("Enviando...");
                   
      },
      success:function(data){
          $('#msgfim').html(data);                       
      }
    });
    
  });  

Share this post


Link to post
Share on other sites

Olá!
Chega vazio de tudo?
Ou só não chega o arquivo?
Pode enviar um exemplo testável pra eu verificar aqui?
Qual é o conteúdo de

property.files[0]

?

Share this post


Link to post
Share on other sites

Ele está fazio no php quando dou print_r($_POST) a array() vem vazia e nós testes de isset($_POST) && (!empty($_POST)) não passa.

property é do campo file no html.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×

Important Information

Ao usar o fórum, você concorda com nossos Terms of Use.