本文整理汇总了PHP中BigTree::formatBytes方法的典型用法代码示例。如果您正苦于以下问题:PHP BigTree::formatBytes方法的具体用法?PHP BigTree::formatBytes怎么用?PHP BigTree::formatBytes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BigTree
的用法示例。
在下文中一共展示了BigTree::formatBytes方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: isset
} else {
$replacing = false;
}
$folder = isset($_POST["folder"]) ? sqlescape($_POST["folder"]) : false;
$f = $_FILES["file"];
$file_name = $replacing ? $replacing : $f["name"];
// If the user doesn't have permission to upload to this folder, throw an error.
$perm = $admin->getResourceFolderPermission($folder);
if ($perm != "p") {
$f["error"] = 9;
}
$error = false;
// Check for file upload errors (or the permission error we faked above)
if ($f["error"]) {
if ($f["error"] == 2 || $f["error"] == 1) {
$error = "The uploaded file was too large. (" . BigTree::formatBytes(BigTree::uploadMaxFileSize()) . " max)";
} elseif ($f["error"] == 9) {
$error = "You do not have permission to upload to this folder.";
} else {
$error = "The upload failed (unknown error).";
}
// File successfully uploaded
} elseif ($f["tmp_name"]) {
$storage = new BigTreeStorage();
$temp_name = $f["tmp_name"];
// See if this file already exists
if ($replacing || !$admin->matchResourceMD5($temp_name, $_POST["folder"])) {
$md5 = md5_file($temp_name);
// Get the name and file extension
$n = strrev($file_name);
$extension = strtolower(strrev(substr($n, 0, strpos($n, "."))));
示例2: foreach
$successes = 0;
// This is an iFrame, so we're going to call the parent from it.
echo '<html><body><script>';
// If the user doesn't have permission to upload to this folder, throw an error.
$perm = $admin->getResourceFolderPermission($folder);
if ($perm != "p") {
echo 'parent.BigTreeFileManager.uploadError("You do not have permission to upload to this folder.");';
} else {
foreach ($_FILES["files"]["tmp_name"] as $number => $temp_name) {
$error = $_FILES["files"]["error"][$number];
$file_name = $replacing ? $replacing : $_FILES["files"]["name"][$number];
// Throw a growl error
if ($error) {
$file_name = htmlspecialchars($file_name);
if ($error == 2 || $error == 1) {
$errors[] = $file_name . " was too large " . BigTree::formatBytes(BigTree::uploadMaxFileSize()) . " max)";
} else {
$errors[] = "Uploading {$file_name} failed (unknown error)";
}
// File successfully uploaded
} elseif ($temp_name) {
// See if this file already exists
if ($replacing || !$admin->matchResourceMD5($temp_name, $_POST["folder"])) {
$md5 = md5_file($temp_name);
// Get the name and file extension
$n = strrev($file_name);
$extension = strtolower(strrev(substr($n, 0, strpos($n, "."))));
// See if it's an image
list($iwidth, $iheight, $itype, $iattr) = getimagesize($temp_name);
// It's a regular file
if ($itype != IMAGETYPE_GIF && $itype != IMAGETYPE_JPEG && $itype != IMAGETYPE_PNG) {