本文整理匯總了PHP中CWizardUtil::CreateThumbnail方法的典型用法代碼示例。如果您正苦於以下問題:PHP CWizardUtil::CreateThumbnail方法的具體用法?PHP CWizardUtil::CreateThumbnail怎麽用?PHP CWizardUtil::CreateThumbnail使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類CWizardUtil
的用法示例。
在下文中一共展示了CWizardUtil::CreateThumbnail方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: SaveFile
function SaveFile($name, $arRestriction = array())
{
$wizard = $this->GetWizard();
$deleteFile = $wizard->GetVar($name . "_del");
$wizard->UnSetVar($name . "_del");
$oldFileID = $wizard->GetVar($name);
$fileNew = $wizard->GetRealName($name . "_new");
if (!array_key_exists($fileNew, $_FILES) || strlen($_FILES[$fileNew]["name"]) <= 0 && $deleteFile === null) {
return;
}
if (strlen($_FILES[$fileNew]["tmp_name"]) <= 0 && $deleteFile === null) {
$this->SetError(GetMessage("MAIN_WIZARD_FILE_UPLOAD_ERROR"), $name . "_new");
return;
}
$arFile = $_FILES[$fileNew] + array("del" => $deleteFile == "Y" ? "Y" : "", "old_file" => intval($oldFileID) > 0 ? intval($oldFileID) : 0, "MODULE_ID" => "tmp_wizard");
$max_file_size = array_key_exists("max_file_size", $arRestriction) ? intval($arRestriction["max_file_size"]) : 0;
$max_width = array_key_exists("max_width", $arRestriction) ? intval($arRestriction["max_width"]) : 0;
$max_height = array_key_exists("max_height", $arRestriction) ? intval($arRestriction["max_height"]) : 0;
$extensions = array_key_exists("extensions", $arRestriction) && strlen($arRestriction["extensions"]) > 0 ? trim($arRestriction["extensions"]) : false;
$make_preview = array_key_exists("make_preview", $arRestriction) && $arRestriction["make_preview"] == "Y" ? true : false;
$error = CFile::CheckFile($arFile, $max_file_size, false, $extensions);
if (strlen($error) > 0) {
$this->SetError($error, $name . "_new");
return;
}
if ($make_preview && $max_width > 0 && $max_height > 0) {
list($sourceWidth, $sourceHeight, $type, $attr) = CFile::GetImageSize($arFile["tmp_name"]);
if ($sourceWidth > $max_width || $sourceHeight > $max_height) {
$success = CWizardUtil::CreateThumbnail($arFile["tmp_name"], $arFile["tmp_name"], $max_width, $max_height);
if ($success) {
$arFile["size"] = @filesize($arFile["tmp_name"]);
}
}
} elseif ($max_width > 0 || $max_height > 0) {
$error = CFile::CheckImageFile($arFile, $max_file_size, $max_width, $max_height);
if (strlen($error) > 0) {
$this->SetError($error, $name . "_new");
return;
}
}
$fileID = (int) CFile::SaveFile($arFile, "tmp");
if ($fileID > 0) {
$wizard->SetVar($name, $fileID);
} else {
$wizard->UnSetVar($name);
}
return $fileID;
}