本文整理汇总了PHP中BigTree::moveFile方法的典型用法代码示例。如果您正苦于以下问题:PHP BigTree::moveFile方法的具体用法?PHP BigTree::moveFile怎么用?PHP BigTree::moveFile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BigTree
的用法示例。
在下文中一共展示了BigTree::moveFile方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: processImageUpload
//.........这里部分代码省略.........
foreach ($field["options"]["thumbs"] as $thumb) {
// We don't want to add multiple errors and we also don't want to waste effort getting thumbnail sizes if we already failed.
if (!$failed && is_array($thumb) && array_filter($thumb)) {
if ($field["options"]["retina"]) {
$thumb["width"] *= 2;
$thumb["height"] *= 2;
}
$sizes = BigTree::getThumbnailSizes($temp_name, $thumb["width"], $thumb["height"]);
if (!BigTree::imageManipulationMemoryAvailable($temp_name, $sizes[3], $sizes[4], $iwidth, $iheight)) {
$bigtree["errors"][] = array("field" => $field["title"], "error" => "Image uploaded is too large for the server to manipulate. Please upload a smaller version of this image.");
$failed = true;
}
}
}
}
if (is_array($field["options"]["center_crops"])) {
foreach ($field["options"]["center_crops"] as $crop) {
// We don't want to add multiple errors and we also don't want to waste effort getting thumbnail sizes if we already failed.
if (!$failed && is_array($crop) && array_filter($crop)) {
list($w, $h) = getimagesize($temp_name);
if (!BigTree::imageManipulationMemoryAvailable($temp_name, $w, $h, $crop["width"], $crop["height"])) {
$bigtree["errors"][] = array("field" => $field["title"], "error" => "Image uploaded is too large for the server to manipulate. Please upload a smaller version of this image.");
$failed = true;
}
}
}
}
}
if (!$failed) {
// Make a temporary copy to be used for thumbnails and crops.
$itype_exts = array(IMAGETYPE_PNG => ".png", IMAGETYPE_JPEG => ".jpg", IMAGETYPE_GIF => ".gif");
// Make a first copy
$first_copy = SITE_ROOT . "files/" . uniqid("temp-") . $itype_exts[$itype];
BigTree::moveFile($temp_name, $first_copy);
// Do EXIF Image Rotation
if ($itype == IMAGETYPE_JPEG && function_exists("exif_read_data")) {
$exif = @exif_read_data($first_copy);
$o = $exif['Orientation'];
if ($o == 3 || $o == 6 || $o == 8) {
$source = imagecreatefromjpeg($first_copy);
if ($o == 3) {
$source = imagerotate($source, 180, 0);
} elseif ($o == 6) {
$source = imagerotate($source, 270, 0);
} else {
$source = imagerotate($source, 90, 0);
}
// We're going to create a PNG so that we don't lose quality when we resave
imagepng($source, $first_copy);
rename($first_copy, substr($first_copy, 0, -3) . "png");
$first_copy = substr($first_copy, 0, -3) . "png";
// Force JPEG since we made the first copy a PNG
$storage->AutoJPEG = true;
// Clean up memory
imagedestroy($source);
// Get new width/height/type
list($iwidth, $iheight, $itype, $iattr) = getimagesize($first_copy);
}
}
// Create a temporary copy that we will use later for crops and thumbnails
$temp_copy = SITE_ROOT . "files/" . uniqid("temp-") . $itype_exts[$itype];
BigTree::copyFile($first_copy, $temp_copy);
// Gather up an array of file prefixes
$prefixes = array();
if (is_array($field["options"]["thumbs"])) {
foreach ($field["options"]["thumbs"] as $thumb) {
示例2:
<?php
$gateway->Service = "linkpoint";
$gateway->Settings["linkpoint-store"] = $_POST["linkpoint-store"];
$gateway->Settings["linkpoint-environment"] = $_POST["linkpoint-environment"];
if ($_FILES["linkpoint-certificate"]["tmp_name"]) {
$filename = BigTree::getAvailableFileName(SERVER_ROOT . "custom/certificates/", $_FILES["linkpoint-certificate"]["name"]);
BigTree::moveFile($_FILES["linkpoint-certificate"]["tmp_name"], SERVER_ROOT . "custom/certificates/" . $filename);
$gateway->Settings["linkpoint-certificate"] = $filename;
}
$gateway->saveSettings();
$admin->growl("Developer", "Updated Payment Gateway");
BigTree::redirect(DEVELOPER_ROOT);
示例3: substr
$d = "classes/" . substr($file, 19);
} elseif (substr($file, 0, 10) == "templates/") {
$d = $file;
} elseif (substr($file, 0, 5) == "site/") {
// Already in the proper directory, should be copied to public, not moved
if (strpos($file, "site/extensions/{$id}/") === 0) {
BigTree::copyFile(SERVER_ROOT . $file, SERVER_ROOT . "extensions/{$id}/public/" . str_replace("site/extensions/{$id}/", "", $file));
// Move into the site/extensions/ folder and then copy into /public/
} else {
BigTree::moveFile(SERVER_ROOT . $file, SITE_ROOT . "extensions/{$id}/" . substr($file, 5));
BigTree::copyFile(SITE_ROOT . "extensions/{$id}/" . substr($file, 5), SERVER_ROOT . "extensions/{$id}/public/" . substr($file, 5));
}
}
// If we have a place to move it to, move it.
if ($d) {
BigTree::moveFile(SERVER_ROOT . $file, SERVER_ROOT . "extensions/{$id}/" . $d);
}
}
}
// If this package already exists, we need to do a diff of the tables, increment revision numbers, and add SQL statements.
$existing = sqlfetch(sqlquery("SELECT * FROM bigtree_extensions WHERE id = '" . sqlescape($id) . "' AND type = 'extension'"));
if ($existing) {
$existing_json = json_decode($existing["manifest"], true);
// Increment revision numbers
$revision = $package["revision"] = intval($existing_json["revision"]) + 1;
$package["sql_revisions"] = (array) $existing_json["sql_revisions"];
$package["sql_revisions"][$revision] = array();
// Diff the old tables
foreach ($existing_json["components"]["tables"] as $table => $create_statement) {
// If the table exists in the new manifest, we're going to see if they're identical
if (isset($package["components"]["tables"][$table])) {
示例4: store
function store($local_file, $file_name, $relative_path, $remove_original = true, $prefixes = array())
{
// If the file name ends in a disabled extension, fail.
if (preg_match($this->DisabledExtensionRegEx, $file_name)) {
$this->DisabledFileError = true;
return false;
}
// If we're auto converting images to JPG from PNG
$file_name = $this->convertJPEG($local_file, $file_name);
// Enforce trailing slashe on relative_path
$relative_path = $relative_path ? rtrim($relative_path, "/") . "/" : "files/";
if ($this->Cloud) {
// Clean up the file name
global $cms;
$parts = BigTree::pathInfo($file_name);
$clean_name = $cms->urlify($parts["filename"]);
if (strlen($clean_name) > 50) {
$clean_name = substr($clean_name, 0, 50);
}
// Best case name
$file_name = $clean_name . "." . strtolower($parts["extension"]);
$x = 2;
// Make sure we have a unique name
while (!$file_name || sqlrows(sqlquery("SELECT `timestamp` FROM bigtree_caches WHERE `identifier` = 'org.bigtreecms.cloudfiles' AND `key` = '" . sqlescape($relative_path . $file_name) . "'"))) {
$file_name = $clean_name . "-{$x}." . strtolower($parts["extension"]);
$x++;
// Check all the prefixes, make sure they don't exist either
if (is_array($prefixes) && count($prefixes)) {
$prefix_query = array();
foreach ($prefixes as $prefix) {
$prefix_query[] = "`key` = '" . sqlescape($relative_path . $prefix . $file_name) . "'";
}
if (sqlrows(sqlquery("SELECT `timestamp` FROM bigtree_caches WHERE identifier = 'org.bigtreecms.cloudfiles' AND (" . implode(" OR ", $prefix_query) . ")"))) {
$file_name = false;
}
}
}
// Upload it
$success = $this->Cloud->uploadFile($local_file, $this->Settings->Container, $relative_path . $file_name, true);
if ($success) {
sqlquery("INSERT INTO bigtree_caches (`identifier`,`key`,`value`) VALUES ('org.bigtreecms.cloudfiles','" . sqlescape($relative_path . $file_name) . "','" . sqlescape(json_encode(array("name" => $file_name, "path" => $relative_path . $file_name, "size" => filesize($local_file)))) . "')");
}
if ($remove_original) {
unlink($local_file);
}
return $success;
} else {
$safe_name = BigTree::getAvailableFileName(SITE_ROOT . $relative_path, $file_name, $prefixes);
if ($remove_original) {
$success = BigTree::moveFile($local_file, SITE_ROOT . $relative_path . $safe_name);
} else {
$success = BigTree::copyFile($local_file, SITE_ROOT . $relative_path . $safe_name);
}
if ($success) {
return "{staticroot}" . $relative_path . $safe_name;
} else {
return false;
}
}
}