Jump to content

Best way to download binary file


mtorbin

Recommended Posts

Thanks guys.  Tried doing this using curl and I'm getting odd results.  The files are downloading exactly as expected, however, each files returns a "false".  The only thing I can think of is that the curl does not actually return a boolean:

 

    if(exec("curl $remoteVideo -o $localVideo")) {
        writeEchoLog("Successfully downloaded " . $videoFileName . ".flv.");
    }
    else {
        writeEchoLog("There was an error downloading " . $videoFileName . ".flv.");
    }
    
    if(exec("curl $remoteImage -o $localImage")) {
        writeEchoLog("Successfully downloaded " . $imageFileName . ".jpg.");
    }
    else {
        writeEchoLog("There was an error downloading " . $imageFileName . ".jpg.\n");
    }

Thanks!  This seems a lot more cryptic then just a straight shell command.  Maybe I'm missing something, but when I looked through the curl_setopt options, i couldn't find one for setting the location of the local file:

 

$file = "my_file.flv";

$curlInit = curl_init("http://myLocation.com/videos/");
$fileReader = fopen($file, "w");

curl_setopt($curlInit, CURLOPT_FILE, $fileReader);
curl_setopt($curlInit, CURLOPT_HEADER, 0);

curl_exec($curlInit);
curl_close($curlInit);
fclose($fileReader);

 

So, the curl session is based upon $curlInit . $file, right?

 

  - MT

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.