Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

193
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!