本文整理汇总了PHP中Server::writeFile方法的典型用法代码示例。如果您正苦于以下问题:PHP Server::writeFile方法的具体用法?PHP Server::writeFile怎么用?PHP Server::writeFile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Server
的用法示例。
在下文中一共展示了Server::writeFile方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: uploadPaths
/**
* Uploades files and creates directories.
* @param string[] relative paths, starts with /
* @return void
*/
private function uploadPaths(array $paths)
{
$prevDir = NULL;
foreach ($paths as $num => $path) {
$remotePath = $this->remoteDir . $path;
$isDir = substr($remotePath, -1) === '/';
$remoteDir = $isDir ? substr($remotePath, 0, -1) : str_replace('\\', '/', dirname($remotePath));
if ($remoteDir !== $prevDir) {
$prevDir = $remoteDir;
$this->server->createDir($remoteDir);
}
if ($isDir) {
$this->writeProgress($num + 1, count($paths), $path, NULL, 'green');
continue;
}
$localFile = $this->preprocess($path);
if ($localFile !== $this->localDir . $path) {
$path .= ' (filters applied)';
}
$this->server->writeFile($localFile, $remotePath . self::TEMPORARY_SUFFIX, function ($percent) use($num, $paths, $path) {
$this->writeProgress($num + 1, count($paths), $path, $percent, 'green');
});
$this->writeProgress($num + 1, count($paths), $path, NULL, 'green');
}
}
示例2: uploadFiles
/**
* Uploades files.
* @return void
*/
private function uploadFiles(array $files)
{
$root = $this->server->getDir();
$prevDir = NULL;
$toRename = [];
foreach ($files as $num => $file) {
$remoteFile = $root . $file;
$isDir = substr($remoteFile, -1) === '/';
$remoteDir = $isDir ? substr($remoteFile, 0, -1) : str_replace('\\', '/', dirname($remoteFile));
if ($remoteDir !== $prevDir) {
$prevDir = $remoteDir;
$this->server->createDir($remoteDir);
}
if ($isDir) {
$this->writeProgress($num + 1, count($files), $file, NULL, 'green');
continue;
}
$localFile = $this->preprocess($orig = $this->local . $file);
if (realpath($orig) !== $localFile) {
$file .= ' (filters applied)';
}
$toRename[] = $remoteFile;
$this->server->writeFile($localFile, $remoteFile . self::TEMPORARY_SUFFIX, function ($percent) use($num, $files, $file) {
$this->writeProgress($num + 1, count($files), $file, $percent, 'green');
});
$this->writeProgress($num + 1, count($files), $file, NULL, 'green');
}
$this->logger->log("\nRenaming:");
foreach ($toRename as $num => $file) {
$this->writeProgress($num + 1, count($toRename), "Renaming {$file}", NULL, 'olive');
$this->server->renameFile($file . self::TEMPORARY_SUFFIX, $file);
}
}