コード例 #1
0
ファイル: cls_util.php プロジェクト: nciftci/codefaster
 private function uploadImage($prefix_stored_filename, $input_filename, $path)
 {
     $save_name = $prefix_stored_filename . "_" . substr(md5("0_" . date("Y-m-d H:i:s") . $input_filename), 0, 12);
     $thumbnail_save_name = "thumb_" . $save_name;
     $fu = new FileUpload($_FILES[$input_filename]);
     $fu->setSave_name($save_name);
     $fu->setSave_path($path);
     if ($fu->doUpload()) {
         $im_crop = new ImageCrop($path . $fu->getSave_name());
         $im_crop->setSave_name($path . $thumbnail_save_name . "." . $fu->getExt());
         //$im_crop->setSave_path ( CATEGORY_IMAGE_PATH );
         list($width, $height) = $im_crop->getImage_size();
         //Scale the image if it is greater than the width set above
         if ($width > IC_CONF_IMAGE_THUMB_WIDTH) {
             $im_crop->setSave_scale(IC_CONF_IMAGE_THUMB_WIDTH / $width);
         } else {
             $im_crop->setSave_scale(1);
         }
         $im_crop->setSave_width($width);
         $im_crop->setSave_height($height);
         if (!$im_crop->doResize()) {
             print_r($im_crop->getErrorMessage());
             exit;
         }
         return $fu->getSave_name();
     } else {
         return false;
     }
 }
コード例 #2
0
ファイル: upload.php プロジェクト: nciftci/codefaster
 } else {
     if ($all_url_vars["action"] == "save" && isset($all_url_vars["upload_thumbnail"])) {
         //	print CONF_INDEX_URL."tmp/".$_SESSION["uploaded_file"];
         //Get the new coordinates to crop the image.
         $x1 = $_POST["x1"];
         $y1 = $_POST["y1"];
         $x2 = $_POST["x2"];
         $y2 = $_POST["y2"];
         $w = $_POST["w"];
         $h = $_POST["h"];
         //	print $y1;
         //	error_log(print_r($_POST,true));
         $im_crop = new ImageCrop($_SESSION["path"] . $_SESSION["uploaded_file"]);
         //Scale the image to the thumb_width set above
         $im_crop->setSave_scale($thumb_width / $w);
         $im_crop->setSave_name($thumb_name);
         $im_crop->setSave_width($w);
         $im_crop->setSave_height($h);
         $im_crop->setStart_width($x1);
         $im_crop->setStart_height($y1);
         if (!$im_crop->doResize()) {
             print_r($im_crop->getErrorMessage());
             exit;
         }
         $im_crop->setSave_scale(1);
         $im_crop->setSave_name($_SESSION["path"] . $_SESSION["uploaded_file"]);
         if (!$im_crop->doResize()) {
             print_r($im_crop->getErrorMessage());
             exit;
         }
         switch ($_SESSION["module"]) {