Thursday, December 23, 2010

Remote download using php curl

Step-stepnya :
1. buat file a.zip dalam folder yang sama dg script php
2. status diubah jadi 666 agar bisa ditimpa hasil download script dibawah ini
3. copy paste script dibawah ini dan jalankan

<?php     $url  = 'http://[domain]/[file].zip';
    $path = './a.zip';

    $fp = fopen($path, 'w');
    if(!$fp) die();

    $ch = curl_init($url);
    curl_setopt($ch, CURLOPT_FILE, $fp);

    $data = curl_exec($ch);

    curl_close($ch);
    fclose($fp);

    echo "Done !";
?>

No comments:

Post a Comment