Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

186
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda