$. getJSON image upload

Asked

Viewed 39 times

1

I need to upload the images along with the BD registration.

   $("#btnCriarConta").click(function() {
        if ($("#inputNomeCondominio").val() !== ""){

            var nomeCondominio  = "Tiago";
            var foto1 = "/data/data/com.intel.appx.IZICondominios.xwalk15/files/_pictures/picture_006.jpg";
            var operacao        = "addCondominio";
            $.getJSON("http://izicondominios.com.br/appOperacoes.php", {operacao:operacao,foto1:foto1}, function(json){

                var msg = json[0].msg;
                alert(msg);

            });

        }

});

PHP file appOperacoes.php:

if($_GET['operacao'] == 'ocorrenciaAdd'){
    move_uploaded_file($_FILES["foto1"]["tmp_name"], "ocorrencias/" . $_FILES["foto1"]["name"]);

    $rs = $mysqli->query("INSERT INTO ocorrencias (id_condominio, foto) VALUES ('".$_GET["condominioID"]."', '".$_GET["foto1"]."' )");
    $registros = mysqli_num_rows($rs);

    if($rs){
        $arr[] = array('msg'=>'sucesso');
    }else{
        $arr[] = array('msg'=>'erro');
    }

    echo json_encode($arr);

    $mysqli->close();
}
  • What’s the problem? What doesn’t work? What errors appear? What did you do to try to debug?

  • Solved your doubt?

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.