title: Setting up proxy for an axis ip camera in PHP
body: <p>I have been searching for a way to proxy a mjpeg stream from the AXIS M1114 Network Camera.</p>
  
  <p>using the following url setup</p>
  
  <pre><code>http://host:port/axis-cgi/mjpg/video.cgi?resolution=320x240&amp;camera=1
  </code></pre>
  
  <p>i try to capture the output and make them available to users with a php script running an apache server on ubuntu.</p>
  
  <p>having browsed the web looking for an answer to no avail i come to you.</p>
  
  <p>my ultimate goal is to have users able to link to the proxy like this:</p>
  
  <pre><code>&lt;img src='proxy.php'&gt;
  </code></pre>
  
  <p>and have the details of all the things in proxy.php.</p>
  
  <p>I have tried using the way of cURL (advised in similar thread here) but i can't get it to work, probably due to lack of knowledge on the inner workings.</p>
  
  <p>currently my very simple proxy.php looks like this</p>
  
  <pre><code>&lt;?php
  
      $camurl =   "http://ip:port";
      $campath =  "axis-cgi/mjpg/video.cgi";
      $userpass = "user:pw";  
  
      $ch = curl_init();
      curl_setopt ($ch, CURLOPT_FOLLOWLOCATION, true);
      curl_setopt($ch, CURLOPT_URL, $camurl + $campath);
      curl_setopt($ch, CURLOPT_POSTFIELDS, 'resolution=320x240&amp;camera=1');
      curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
      curl_setopt($ch, CURLOPT_USERPWD, $userpass);
      $result = curl_exec($ch);
  
      header('Content-type: image/jpeg'); 
      echo $result;           
      curl_close($ch);
  ?&gt;
  </code></pre>
  
  <p>My understanding is that this would produce an acceptable output for my plan. But alas. </p>
  
  <p>My question would be if there is a blatant error i do not see. Any simpler option/way of getting the result i aim for is welcome too. </p>
  
  <p>Please point me in the right direction. I happily provide any relevant information i might have missed to provide. Thank you in advance.</p>
  
  <p>solved edit:</p>
  
  <p>After commenting out:</p>
  
  <pre><code>curl_setopt ($ch, CURLOPT_FOLLOWLOCATION, true);
  </code></pre>
  
  <p>changing </p>
  
  <pre><code>curl_setopt($ch, CURLOPT_URL, $camurl + $campath);
  </code></pre>
  
  <p>to</p>
  
  <pre><code>curl_setopt($ch, CURLOPT_URL, $camurl . $campath);  (mixing up some languages)
  </code></pre>
  
  <p>and most importantly removing a space in the .php file so that the header is actually the header it sort of does what i wanted. </p>