Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9318903
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 19, 20262026-06-19T03:15:04+00:00 2026-06-19T03:15:04+00:00

I have a webcam via Android IP Camera App. I’m writing a php script

  • 0

I have a webcam via Android IP Camera App. I’m writing a php script perform an OCR on a temperature sensor to read the digits and warn me when it goes past a specific temperature. The URL I wish to grab is a shot.jpg via the cam’s IP, however the webcam has a username and password of authorization: basic. I was able to get through the authentication with the first method, but it simply outputs a shit ton of random characters. The second method loads a picture, but the src is incorrect. Any suggestions on how to properly format the first method with the content-type would be amazing. Thanks

//METHOD 1
    $context = stream_context_create(array(
    'http' => array('header'  => "Authorization: Basic " . base64_encode("$username:$password"))
));
$data = file_get_contents($url, false, $context);
echo $data;


//METHOD NUMBER 2
header('Authorization: Basic' . base64_encode("$username:$password"));
header('Content-Type: image/jpg');
$data = file_get_contents($url, false);
echo $data;
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-19T03:15:05+00:00Added an answer on June 19, 2026 at 3:15 am

    You’re not outputting the correct Content-Type: in example 1. file_get_contents does not pass it on. So the image will be sent to the browser under the assumption it were a HTML page.

    This way:

    $data = file_get_contents($url, false, $context);
    header('Content-Type: image/jpg');    
    echo $data;
    

    Also, try curl (which also supports HTTP), for simplifying the login credential use.

    In your second example you are using a page response header(). The Authorization: line will not be passed over the file_get_contents() URL request there.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a webcam script that sends a JPG via FTP to my webserver
I have the source code for taking a picture via webcam, but I need
I want to use the webcam as camera in android emulator . I referred
I have an application written in C that captures an image via webcam,does some
I have a small app for taking a webcam image and putting this image
I have a webcam directly over a chicken nest. This camera takes images and
I have an image http://img831.imageshack.us/img831/2935/dotn.png which should be recognized via a webcam. So this
I am simulating a thermal camera effect. I have a webcam at a party
I have an app that captures image from webcam,I convert it to bitmap, now
I have a webcam that works by re-uploading the same file and overwriting itself

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.