アイデアを得るためにこの実装を調べてください。
/**
 * Save the file to the specified path
 * @return boolean TRUE on success
 */
function save($path) {    
    $input = fopen("php://input", "r");
    $temp = tmpfile();
    $realSize = stream_copy_to_stream($input, $temp);
    fclose($input);
    if ($realSize != $this->getSize()){            
        return false;
    }
    $target = fopen($path, "w");        
    fseek($temp, 0, SEEK_SET);
    stream_copy_to_stream($temp, $target);
    fclose($target);
    return true;
}
私は自分のプロジェクトの1つでそのような実装を使用しています:
$savePath = '/home/user/uploaded_files/picture.png';
if(!isset($_FILES['qqfile']['tmp_name'])) {
    $input = fopen('php://input', 'r');
    $temp = tmpfile();
    stream_copy_to_stream($input, $temp);
    fclose($input);
    $target = fopen($savePath, 'w');
    fseek($temp, 0, SEEK_SET);
    stream_copy_to_stream($temp, $target);
    fclose($target);
} else {
    move_uploaded_file($_FILES['qqfile']['tmp_name'], $savePath);
}