how to let php file to show image?

Discussion in 'PHP' started by feelexit, Dec 1, 2006.

  1. #1
    flash has security setting. stop you to display image from another domain name.

    I am thinking about to have php file to show images.

    www .mydomain.com/showimage.php ?ur=www.yahoo.com/logo.gif -- just example

    I can use phpthumb, but it creates image cache , leave it on my space. every time when visitors see the image, it goes my web site, it wastes alot of my bandwidth.

    is there a way to use php file to show exteral image, but not saving a copy on my host?



    Ifound this solution, but not sure about the performance. if I have thousand users display images simultaniously. not sure it still gonna work. and images still come out from my web site, so still waste my bandwidth, how to solve this problem.

    please help me out.


    // put ...php?src=IMAGEURL

    header("Content-type: image/jpeg");
    $file = fopen ($_GET["src"], "r");
    if (!$file) {
    echo "Unable to open remote file.\n";
    exit;
    }
    while (!feof ($file)) {
    $line = fgets ($file, 1024);
    echo $line;
    }
    fclose($file);
     
    feelexit, Dec 1, 2006 IP
  2. Pat Gael

    Pat Gael Banned

    Messages:
    1,331
    Likes Received:
    68
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Pat Gael, Dec 1, 2006 IP
  3. feelexit

    feelexit Peon

    Messages:
    143
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    hi, thanx for help. but that not gonna solve the problem.

    flash has security setting. it stops your to link other domain and load from other domain. this is a really annoying feature they have.
     
    feelexit, Dec 1, 2006 IP
  4. CodyRo

    CodyRo Peon

    Messages:
    365
    Likes Received:
    15
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Use the imagecreatefrom__() functions. Just create a switch statement when grabbing the file so you know the proper one to use depending on the image.
     
    CodyRo, Dec 2, 2006 IP