CLENT CRUMLEY
  • Design
  • Development
  • Strategy
  • Contact
BarkBox.com

Home // Snippets // Move or migrate files from one location to another

  • July 8th
  • 2016

Move or migrate files from one location to another

// smooth download function
function download($file_source, $file_target) {

    $rh = fopen($file_source, 'rb');
    $wh = fopen($file_target, 'w+b');
    if (!$rh || !$wh) {
        return false;
    }

    while (!feof($rh)) {
        if (fwrite($wh, fread($rh, 4096)) === FALSE) {
            return false;
        }
        echo ' ';
        flush();
    }
  
    fclose($rh);
    fclose($wh);

    return true;
}

Posted in PHP by clent

Posted in Snippets by clent

~ ★ ~

Ready to get started?

I'm currently creating opportunity in Central Texas & would love the chance to be a part of your next web endeavor.

Fill out a short questionnaire and let's make some magic happen.

Start Project »
  • Design
  • Development
  • Strategy
  • Contact