Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

185
Visualizações
file_get_contents(): Content-type not specified assuming application/x-www-form-urlencoded

i have a project by php and javascript ... I have a Call an API from Camera by Php code. I used (file_get_contents) function and Post request: this Code:


$value = $_POST['TakeNewPic'];

function Takepic(){
    $Parametrs = $value;
    $opts = array(
       
  
      "user" => "THETAYN10113693",
     "password" => "10113693",
     "name" => $Parametrs
  
     );

  $post = json_encode($opts);              
$context  = stream_context_create(array(
'http' => array(

    'method' => "POST",
    'timeout' => 60,
    'content' => $post,
    'header'  => "Content-Type : application/json"



   )

));
$url = 'http://192.168.1.1/osc/commands/execute';//.$https_server;
$result = file_get_contents($url,false, $context);


echo json_encode($result);

//}

}

this code is working and Camera take picture but problem is that I alway get this Notice :

Notice: file_get_contents(): Content-type not specified assuming application/x-www-form-urlencoded in C:\xampp7.3\htdocs\CameraTest\function.php on line 63

And I send Values to php file by Ajax Call from Java Script File this is code in Java script file :

function getCamInfo(value)
{



var body = "TakeNewPic=" + value ;

var req = new XMLHttpRequest();




req.onreadystatechange = function ()
{

    if(this.readyState === 4 && this.status === 200){

     var res = document.getElementById("parg");
     res.innerHTML =this.responseText;



    }


}

req.open (
  
  "POST",
  "post_req.php",
  true,
  );

req.setRequestHeader(

    "content-type",
    "application/x-www-form-urlencoded"
    
    );

  req.send(body);

}



 

  document.getElementById("butt").onclick = function ()
  {
    getCamInfo("camera.takePicture");
  //console.log(AllInfo);

  }

please i want no more get this Notice I hope your help and thanks so much

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Looking at the implementation (e.g. PHP 7.4.0, PHP 8.1.0), it looks like the header won't be detected if there is a space between the header name and the colon. This is possibly a bug, but one that's easy to work around - instead of:

'header'  => "Content-Type : application/json"

Try:

'header'  => "Content-Type: application/json"
about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda