Results 1 to 2 of 2

Thread: display image from url

Hybrid View

  1. #1
    Join Date
    Jun 2014

    display image from url

    I am having trouble with displaying an image from a url. In the following code if I echo out $test I get the url of the image. However, in the current code I am trying to display the image, but the only thing that gets displayed is a small broken image in the upper left. The images I am trying to display are not located on my server.
    PHP Code:
    $html file_get_contents($website.$criteria); 

    $dom = new DOMDocument;


    $links $dom->getElementsByTagName('img');

    foreach (
    $links as $link){
    $test $link->getAttribute('src');

  2. #2
    Join Date
    Aug 2004
    Well, you can't display more than one image per HTTP request, so simply looping over the list of image URLs and dumping their contents into the output buffer is not going to work (assuming your PHP config even has the allow_url_fopen setting enabled).

    Why not just output your own <img> tags at that point using the URLs as the src value? (Although I'm guessing that the value of $test may not always be a fully qualified URL, so that might not work without some additional code to analyze it and add the "http://domain/" part, and possibly the path, as well.)
    "Well done....Consciousness to sarcasm in five seconds!" ~ Terry Pratchett, Night Watch

    How to Ask Questions the Smart Way (not affiliated with this site, but well worth reading)

    My Blog
    cwrBlog: simple, no-database PHP blogging framework

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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