1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

include a file from a different domain help please

Discussion in 'PHP' started by simon369, Aug 21, 2008.

  1. #1
    could somebody please tell me how i would go about including a file from domain a in domain b
    e.g. i want to load something from domain a in domain b. i have tried php include wih no success

    thanks
    SEMrush
     
    simon369, Aug 21, 2008 IP
    SEMrush
  2. Sam Designs

    Sam Designs Active Member

    Messages:
    474
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    60
    #2
    Why not just upload the file to your server?
     
    Sam Designs, Aug 21, 2008 IP
  3. simon369

    simon369 Active Member

    Messages:
    1,712
    Likes Received:
    47
    Best Answers:
    0
    Trophy Points:
    90
    #3
    because i have about 10 + domains that need to load the file and it changes every few days
     
    simon369, Aug 21, 2008 IP
  4. rohan_shenoy

    rohan_shenoy Active Member

    Messages:
    441
    Likes Received:
    20
    Best Answers:
    0
    Trophy Points:
    60
    #4
    Use one of the following:
    
    fopen()
    file_get_contents()
    CURL functions
    
    PHP:
     
    rohan_shenoy, Aug 21, 2008 IP
  5. ecolatur

    ecolatur Well-Known Member

    Messages:
    1,141
    Likes Received:
    71
    Best Answers:
    0
    Trophy Points:
    160
    #5
    I wonder why this cannot work in DomainB.com site page:

    <?php include("http://www.domainA.com/yourfile.php");?> 
    Code (markup):
    Did u try exactly this?
     
    ecolatur, Aug 21, 2008 IP
  6. simon369

    simon369 Active Member

    Messages:
    1,712
    Likes Received:
    47
    Best Answers:
    0
    Trophy Points:
    90
    #6
    yes i tried that exacely.

    could you please give me a real example of f open or the other one

    thanks
     
    simon369, Aug 21, 2008 IP
  7. ecolatur

    ecolatur Well-Known Member

    Messages:
    1,141
    Likes Received:
    71
    Best Answers:
    0
    Trophy Points:
    160
    #7
    ecolatur, Aug 21, 2008 IP
  8. simon369

    simon369 Active Member

    Messages:
    1,712
    Likes Received:
    47
    Best Answers:
    0
    Trophy Points:
    90
    #8
    thanks, i think it might just be blocked from my host cos nothing seems to work

    thanks
     
    simon369, Aug 21, 2008 IP
  9. Barti1987

    Barti1987 Well-Known Member

    Messages:
    2,659
    Likes Received:
    110
    Best Answers:
    0
    Trophy Points:
    155
    #9
    If you can edit or emulate php.ini, change/add:

    allow_url_include = on

    It will allow you to include URLs.

    Peace,
     
    Barti1987, Aug 21, 2008 IP
  10. lfhost

    lfhost Peon

    Messages:
    232
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    0
    #10
    use curl

    
    <?php
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, "http://www.domain.com");
    curl_setopt($ch, CURLOPT_HEADER, 0);
    curl_exec($ch);
    curl_close($ch);
    ?> 
    
    PHP:
    replace http://www.domain.com with the file you want to grab.
     
    lfhost, Aug 21, 2008 IP
  11. Ilyes

    Ilyes Banned

    Messages:
    129
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
  12. ghprod

    ghprod Active Member

    Messages:
    1,010
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    78
    #12
    i think bcoz security problem .. we can't include form other domain .. but u can get it with cURL or get_content :D
     
    ghprod, Aug 22, 2008 IP