Send photo and json in the same request - Postman

0

I'm having trouble sending a photo and a json by postman on the same request.

Ineedtosendtheprofilepictureoftheuserandatthesametimereceiveajsonwiththedataofthesame.

//InstânciadaentidadeLogin$login=newLogin();//recuperandooparâmetroobjetologindojson$fk_login_cidadao=$request->getParam('fk_login_cidadao');//setandovaloresdoobjetologin$login->setLogin($fk_login_cidadao['login']);$login->setEmail($fk_login_cidadao['email']);$login->setSenha($fk_login_cidadao['senha']);$login->setStatus_login($fk_login_cidadao['status_login']);$login->setAsAdministrador($fk_login_cidadao['administrador']);//salvandologin$entityManager->persist($login);$entityManager->flush();//buscandologinrecémsalvo$loginRepository=$entityManager->getRepository('App\Models\Entity\Login');//pegandologin$loginCidadao=$loginRepository->find($login->getId_login());//Salvarfoto$files=$request->getUploadedFiles();$newimage=$files['foto'];if($newimage->getError()===UPLOAD_ERR_OK){$uploadFileName=$newimage->getClientFilename();$type=$newimage->getClientMediaType();$name=uniqid('img-'.date('d-m-y').'-');$name.=$newimage->getClientFilename();//$imgs[]=array('url'=>'/Photos/'.$name);//localserver$newimage->moveTo("C:\Users\jvict\PhpstormProjects\api.webservice\img");#/home/citycare/Imgs/User/$name

            //localdev
            $photoURL = "C:\Users\jvict\PhpstormProjects\api.webservice\img";#/home/citycare/Imgs/User/$name

        }

        //Instância da entidade Cidadao
        $cidadao = new Cidadao();
        //setando valores do objeto cidadao
        $cidadao ->setFk_login_cidadao($loginCidadao);
        $cidadao->setNome($request->getParam('nome'));
        $cidadao->setSexo($request->getParam('sexo'));
        $cidadao ->setSobrenome($request->getParam('sobrenome'));
        $cidadao ->setEstado($request->getParam('estado'));
        $cidadao ->setCidade($request->getParam('cidade'));
        $cidadao ->setDir_foto_usuario($request->getParam($photoURL));
        $entityManager->persist($cidadao);
        $entityManager->flush();
        //retornando confirmação do evento completo
        $return = $response->withJson(["result" => true],201)->withHeader('Content-type', 'application/json');
    
asked by anonymous 09.10.2017 / 17:39

0 answers