$ .getJSON image upload

1

I need to upload the images along with the registration in the DB.

   $("#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();
}
    
asked by anonymous 19.12.2015 / 20:08

0 answers