当前位置: 首页>>代码示例>>PHP>>正文


PHP sapp_Global::smartresizeimage方法代码示例

本文整理汇总了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;
 }
开发者ID:rajbrt,项目名称:sentrifugo,代码行数:67,代码来源:OrganisationinfoController.php


注:本文中的sapp_Global::smartresizeimage方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。