Enjoy unlimited access to all forum features for FREE! Optional upgrade available for extra perks.

return an image securely

Discussion in 'Scripts and Coding' started by dee, May 31, 2018.

  1. dee

    dee Well-Known Member Acorn Supporter

    Joined:
    May 2013
    Posts:
    2,592
    Likes Received:
    404
    I'm building a custom interface for a wecam installation using the camera built in cgi commands. Does anyone know how i can return am image from the camera securely using php so the camera password/user isnt exposed. SO.... I can call the image in an img tag directly using this url:

    HTML:
    http://1.2.3.4:88/CGIProxy.fcgi?cmd=snapPicture2&usr=usernamehere&pwd=passwordforcamera
    What i'd like to do is call :

    HTML:
    <img src="https://server/image.php">
    And the php script return the image so passwords and ip's arent exposed browser side. Hope that makes sense . Thanks in advance for any help
     
  2. Domain Forum

    Acorn Domains Elite Member

    Joined:
    1999
    Messages:
    Many
    Likes Received:
    Lots
    IWA Meetup
     
  3. RobM

    RobM Retired Member

    Joined:
    Mar 2012
    Posts:
    3,273
    Likes Received:
    470
    Use your php to get the contents of the webcam into a variable. Then just echo the contents out but set the mime type.
    eg
    <?
    // get the contents of the camera into a variable (say $contents)
    header('Content-Type: image/jpeg');
    echo $contents;
    ?>
    It all depends on how the data is put out from the source originally.
     
  4. RobM

    RobM Retired Member

    Joined:
    Mar 2012
    Posts:
    3,273
    Likes Received:
    470
  5. dee

    dee Well-Known Member Acorn Supporter

    Joined:
    May 2013
    Posts:
    2,592
    Likes Received:
    404
    Thanks @RobM

    I just get a dead image icon so camera must be putting out something weird. If i download from original source url its just a .jpeg
     
  6. RobM

    RobM Retired Member

    Joined:
    Mar 2012
    Posts:
    3,273
    Likes Received:
    470
    Check it first in a page of its own - ie not in an img tag - just a page that will get the contents and display as mime type jpeg straight away
     
  7. dee

    dee Well-Known Member Acorn Supporter

    Joined:
    May 2013
    Posts:
    2,592
    Likes Received:
    404
    Aaah... okay. It seems to show as as some cgi proxy