SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Zealot secoif's Avatar
    Join Date
    Jul 2006
    Location
    Brisbane, Australia
    Posts
    144
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    save content from an iframe to a file?

    We use the services of an external company in our website. We load this content in via an iframe.
    Some of this content happens to be an image.
    This image is only stored on the external company's site for a limited time.
    We need this image to be stored on our servers somehow.
    Because the content is loaded dynamically from another site it's a little more difficult to access via a server side script
    I'm thinking it would go something like:
    load in the html for the iframe into a variable,
    (no idea how yet, I don't think 'include' works like that)
    then scan through the file for the link to the image,
    (would be easy with javascript selectors)
    then request that url from them and save it as a file somewhere.

    I can't think how i can do this easily with php nor ajax... any ideas?
    This should work:
    maybe something like, use javascript to find the element url, then send a request to another page with a server side script to handle saving the url
    ...but I'm thinking there might be a better way of doing it.

    The people who made the application I'm supposed to be maintaining/extending didn't care for users with no javascript (i know, i know), so because other key functionality doesn't work without javascript (at current...but I'm rebuilding the whole thing at some point but this is a priority feature for asap) i'm not worrying about making sure it works for users without javascript.

    I use mootools for my javascript framework so a solution using mootools would be good but any solution will do and I'll adapt it to mootools.

  2. #2
    SitePoint Wizard gRoberts's Avatar
    Join Date
    Oct 2004
    Location
    Birtley, UK
    Posts
    2,439
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Your best off using PHP as technically iframes do not allow you to see the content if the src is not in teh same domain as you.

    You can load the web page in PHP and then use regex to get all the links.



Bookmarks

Posting Permissions

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