Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    Regular Coder
    Join Date
    Jun 2002
    Location
    Montreal, Canada
    Posts
    644
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Grabbing remote page, links/imgs don't work..

    When you include a page from another php page on a different domain all the images and links are relative, so none f them work. Is there any way to fix this aside from writting a script that searches for common references (src=,href=,...). Because If I do that, javascripts urls will be much harder. Is there a way to get the file with absolute paths?

  • #2
    New Coder
    Join Date
    Jan 2003
    Location
    Tulsa, OK
    Posts
    69
    Thanks
    0
    Thanked 0 Times in 0 Posts
    When files are included the source targets are originating from the folder that the script that includes the file is in. Example, say you have the main script in /fun and the include in /fun/includes.

    In the included script you have to set all of the non-absolute links to show as if the script was in the /fun folder. so if your images folder is /images the image links in the main script as well as the unclude have to be images/file.ext.

    You're probably setting the images like ../images/file.ext in the include file. Or so thats what it seems.

    Let me know if that helped.

  • #3
    Regular Coder
    Join Date
    Jun 2002
    Location
    UK
    Posts
    577
    Thanks
    0
    Thanked 0 Times in 0 Posts
    if you had to add "http://domain.whatever/folder/folder before each image that didn't have that, you'd need some form of clever regex.

    a sneaky (and also untested) workaround it to sling a <base href=" at the top of their included output - that should ignore hrefs and srcs that start http and just effect the rest.

    echo '<base href="' .substr($file,0,strrpos('/',$file)). '">';

    couldn't remember which way the strrpos accepts its parameters either.
    Ökii - formerly pootergeist
    teckis - take your time and it'll save you time.


  •  

    Posting Permissions

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