本文整理汇总了PHP中OC_Filesystem::fromTmpFile方法的典型用法代码示例。如果您正苦于以下问题:PHP OC_Filesystem::fromTmpFile方法的具体用法?PHP OC_Filesystem::fromTmpFile怎么用?PHP OC_Filesystem::fromTmpFile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OC_Filesystem
的用法示例。
在下文中一共展示了OC_Filesystem::fromTmpFile方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: pull
/**
* pull a file from a remote server
* @param string source
* @param string token
* @param string dir
* @param string file
* @return string guessed mime type
*/
static function pull($source, $token, $dir, $file)
{
$tmpfile = tempnam(get_temp_dir(), 'remoteCloudFile');
$fp = fopen($tmpfile, 'w+');
$url = $source .= "/files/pull.php?token={$token}";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_FILE, $fp);
curl_exec($ch);
fclose($fp);
$info = curl_getinfo($ch);
$httpCode = $info['http_code'];
curl_close($ch);
if ($httpCode == 200 or $httpCode == 0) {
OC_Filesystem::fromTmpFile($tmpfile, $dir . '/' . $file);
return true;
} else {
return false;
}
}
示例2: foreach
exit;
}
}
$files = $_FILES['files'];
$dir = $_POST['dir'];
$error = '';
$totalSize = 0;
foreach ($files['size'] as $size) {
$totalSize += $size;
}
if ($totalSize > OC_Filesystem::free_space('/')) {
OCP\JSON::error(array("data" => array("message" => "Not enough space available")));
exit;
}
$result = array();
if (strpos($dir, '..') === false) {
$fileCount = count($files['name']);
for ($i = 0; $i < $fileCount; $i++) {
$target = OCP\Files::buildNotExistingFileName(stripslashes($dir), $files['name'][$i]);
if (is_uploaded_file($files['tmp_name'][$i]) and OC_Filesystem::fromTmpFile($files['tmp_name'][$i], $target)) {
$meta = OC_FileCache::get($target);
$id = OC_FileCache::getId($target);
$result[] = array("status" => "success", 'mime' => $meta['mimetype'], 'size' => $meta['size'], 'id' => $id, 'name' => basename($target));
}
}
OCP\JSON::encodedPrint($result);
exit;
} else {
$error = 'invalid dir';
}
OCP\JSON::error(array('data' => array('error' => $error, "file" => $fileName)));