本文整理汇总了PHP中sapp_Global::smartresizeimage方法的典型用法代码示例。如果您正苦于以下问题:PHP sapp_Global::smartresizeimage方法的具体用法?PHP sapp_Global::smartresizeimage怎么用?PHP sapp_Global::smartresizeimage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sapp_Global
的用法示例。
在下文中一共展示了sapp_Global::smartresizeimage方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: imageupload
public function imageupload()
{
$savefolder = USER_PREVIEW_UPLOAD_PATH;
// folder for upload
$max_size = 1024;
// maxim size for image file, in KiloBytes
// Allowed image types
//$allowtype = array('gif', 'jpg', 'jpeg', 'png');
$allowtype = array('gif', 'jpg', 'jpeg', 'png', 'GIF', 'JPG', 'JPEG', 'PNG');
/** Uploading the image **/
$rezultat = '';
$result_status = '';
$result_msg = '';
// if is received a valid file
if (isset($_FILES['profile_photo'])) {
$type = explode(".", strtolower($_FILES['profile_photo']['name']));
//echo in_array($type, $allowtype);exit;
if (in_array($type[1], $allowtype)) {
// check its size
if ($_FILES['profile_photo']['size'] != 0 && $_FILES['profile_photo']['size'] <= $max_size * 1024) {
// if no errors
if ($_FILES['profile_photo']['error'] == 0) {
//$newname = 'preview_'.date("His").'.'.$type[1];
$newname = 'organisation_image_' . time() . '.' . $type[1];
$thefile = $savefolder . "/" . $_FILES['profile_photo']['name'];
$newfilename = $savefolder . "/" . $newname;
$filename = $newname;
if (!move_uploaded_file($_FILES['profile_photo']['tmp_name'], $newfilename)) {
$rezultat = '';
$result_status = 'error';
$result_msg = 'The file cannot be uploaded, try again.';
} else {
$rezultat = $filename;
$setWidth = 265;
$setHeight = 40;
list($imgwidth, $imgheight) = getimagesize($newfilename);
if ($imgwidth < 265) {
$setWidth = $imgwidth;
}
if ($imgheight < 40) {
$setHeight = $imgheight;
}
if ($imgwidth > 265 || $imgheight > 40) {
sapp_Global::smartresizeimage($newfilename, $setWidth, $setHeight, false, 'file', false, false);
}
$result_status = 'success';
$result_msg = '';
}
}
} else {
$rezultat = '';
$result_status = 'error';
$result_msg = 'Image size must not exceed ' . $max_size . ' KB.';
}
} else {
$rezultat = '';
$result_status = 'error';
$result_msg = 'Please upload only .gif, .jpg, .jpeg, .png images.';
}
} else {
$rezultat = '';
$result_status = 'error';
$result_msg = 'Please upload only .gif, .jpg, .jpeg, .png images.';
}
$result = array('result' => $result_status, 'img' => $rezultat, 'msg' => $result_msg);
return $result;
}