Php Problem

Discussion in 'PHP' started by asadul, Jul 6, 2009.

  1. #1
    How to write a code in php to download a file.?? :eek:
     
    asadul, Jul 6, 2009 IP
  2. Bohra

    Bohra Prominent Member

    Messages:
    12,573
    Likes Received:
    537
    Best Answers:
    0
    Trophy Points:
    310
    #2
    ??? what do you exactly mean
     
    Bohra, Jul 6, 2009 IP
  3. www.amagit.com

    www.amagit.com Peon

    Messages:
    87
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #3
    $myFileContents = file_get_contents("http://www.example.com/");
    Code (markup):
    Then use the variable as needed. It will contain the string contents of the file.

    Make sure this is set in your php.ini file:
    allow_url_fopen = On
    
    Code (markup):
     
    www.amagit.com, Jul 6, 2009 IP
  4. kmap

    kmap Well-Known Member

    Messages:
    2,215
    Likes Received:
    29
    Best Answers:
    2
    Trophy Points:
    135
    #4
    <?
    $name="abc.zip";
    $url="http://www.abc.com/abc.zip";
    
    $ch = curl_init($url);
    $fp = fopen($name, "w");
    
    curl_setopt($ch, CURLOPT_FILE, $fp);
    curl_setopt($ch, CURLOPT_HEADER, 0);
    curl_setopt ($ch, CURLOPT_TIMEOUT, 12000);
    
    curl_exec($ch);
    curl_close($ch);
    fclose($fp);
    ?>
    PHP:
     
    kmap, Jul 6, 2009 IP
  5. Bohra

    Bohra Prominent Member

    Messages:
    12,573
    Likes Received:
    537
    Best Answers:
    0
    Trophy Points:
    310
    #5
    if you mean transfer file to ur server than u can also use copy command
     
    Bohra, Jul 6, 2009 IP