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

184
Views
file_get_contents (): tipo de contenido no especificado asumiendo application/x-www-form-urlencoded

tengo un proyecto por php y javascript ... Tengo una llamada a una API desde la cámara por código Php. Usé la función (file_get_contents) y la solicitud de publicación: este código:

 $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); //} }

este código funciona y la cámara toma una foto, pero el problema es que siempre recibo este aviso:

Aviso: file_get_contents(): tipo de contenido no especificado asumiendo application/x-www-form-urlencoded en C:\xampp7.3\htdocs\CameraTest\function.php en la línea 63

Y envío valores al archivo php mediante Ajax Call desde Java Script File, este es el código en el archivo de script Java:

 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); }

por favor no quiero mas reciba este aviso espero su ayuda y muchas gracias

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Mirando la implementación (por ejemplo, PHP 7.4.0 , PHP 8.1.0 ), parece que el encabezado no se detectará si hay un espacio entre el nombre del encabezado y los dos puntos. Es posible que se trate de un error, pero es fácil solucionarlo, en lugar de:

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

Probar:

 '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!