dcsimg
Results 1 to 2 of 2

Thread: JPG that gets live data from a Webpage

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Mar 2007
    Posts
    183

    JPG that gets live data from a Webpage

    I'm just wondering if there is any way to create a JPG file that loads data from the Web. This would allow me to do things like upload a JPG file that shows live data on a Website where the data I want to show is impossible to show any other way. For example, suppose I want to show a random picture on a Website, but I can only upload one picture at a time. In this case, having one JPG file that tells the computer to load a PHP page that then returns any one picture would be useful.
    Do not read this sentence.
    You read that last one, didn't you?
    Darn. You now read the previous two.

    Check out my pins on Pinterest!

  2. #2
    Freelancer akhileshbc's Avatar
    Join Date
    Jun 2008
    Location
    Trivandrum, Kerala, India
    Posts
    7,647

    Re: JPG that gets live data from a Webpage

    Just use the a PHP page as the source for the image tag. And then in that PHP page, write the code to pick the random image or whatever image you want to and out it.

    Eg:
    Code:
    <img src="http://www.yoursite.com/somedirectory/generate.php" />
    In generate.php file, you would write something like this:

    PHP Code:
    <?php

      $picture 
    'mypath/to/image/location/my_image.jpg'// you can pick an image randomly if needed
      
    $type 'image/jpeg'// This is the content type we are going to use. ie, we would be going to tell the browser that that content outputted is of type JPG image, by using the header() function below
      
      
    header('Content-Type:'.$type); //send the headers to the browser
      
    readfile($picture); // read the file contents and write to the output buffer.

    ?>
    That would be enough.
    Last edited by akhileshbc; May 2nd, 2013 at 11:16 AM.

    If my post was helpful to you, then express your gratitude using Rate this Post.
    And if your problem is SOLVED, then please Mark the Thread as RESOLVED (see it in action - video)
    My system: AMD FX 6100, Gigabyte Motherboard, 8 GB Crossair Vengance, Cooler Master 450W Thunder PSU, 1.4 TB HDD, 18.5" TFT(Wide), Antec V1 Cabinet

    Social Group: VBForums - Developers from India


    Skills: PHP, MySQL, jQuery, VB.Net, Photoshop, CodeIgniter, Bootstrap,...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width