Beispiel #1
0
 public function imguploadAction()
 {
     if ($this->_request->isPost()) {
         /* Uploading Document File on Server */
         $upload = new Zend_File_Transfer_Adapter_Http();
         $upload->setDestination("tmp");
         try {
             // upload received file(s)
             $upload->receive();
             $t = $upload->getFileInfo();
             $oldfilename = $t['Filedata']['name'];
             $idgallery = $this->_getParam('item', null);
             list($status, $idimage) = Model_Image::addImage($idgallery);
             if (!$status) {
                 return false;
             }
             $filename = $idimage . ".jpg";
             copy("tmp/" . $oldfilename, 'public/gallery/full/' . $idgallery . '_' . $filename);
             unlink("tmp/" . $oldfilename);
             $ar = getimagesize('public/gallery/full/' . $idgallery . '_' . $filename);
             $res2width = true;
             if ($ar[0] < $ar[1]) {
                 $res2width = false;
             }
             $image_mid = new Asido_Image('public/gallery/full/' . $idgallery . '_' . $filename, 'public/gallery/mid/' . $idgallery . '_' . $filename);
             $image_small = new Asido_Image('public/gallery/full/' . $idgallery . '_' . $filename, 'public/gallery/small/' . $idgallery . '_' . $filename);
             $image_big = new Asido_Image('public/gallery/full/' . $idgallery . '_' . $filename, 'public/gallery/big/' . $idgallery . '_' . $filename);
             $asido = new Asido_Api();
             //$asido_drive =
             $asido->_driver(new Asido_Driver_GD());
             //mid
             //                if ($res2width && (($ar[0] / $ar[1]) > 1.5 )) {
             //                    $asido->height($image_mid, 144);
             //                } else {
             //                    $asido->width($image_mid, 216);
             //                }
             //$asido->crop($image_mid, 0, 0, 216, 144);
             $asido->frame($image_mid, 216, 144, Asido_Api::color(0, 0, 0));
             $image_mid->save(ASIDO_OVERWRITE_ENABLED);
             //big
             //                if ($res2width && (($ar[0] / $ar[1]) > 1.75 )) {
             //                    $asido->height($image_big, 400);
             //                } else {
             //                    $asido->width($image_big, 700);
             //                }
             //                $asido->crop($image_big, 0, 0, 700, 400);
             $asido->frame($image_big, 700, 400, Asido_Api::color(0, 0, 0));
             $image_big->save(ASIDO_OVERWRITE_ENABLED);
             //                if ($res2width) {
             //                    $asido->height($image_small, 70);
             //                } else {
             //                    $asido->width($image_small, 70);
             //                }
             //$asido->crop($image_small, 0, 0, 70, 70);
             $asido->frame($image_small, 70, 70, Asido_Api::color(0, 0, 0));
             $image_small->save(ASIDO_OVERWRITE_ENABLED);
             // update permition
             @chmod('public/gallery/full/' . $idgallery . '_' . $filename, 0777);
             @chmod('public/gallery/big/' . $idgallery . '_' . $filename, 0777);
             @chmod('public/gallery/mid/' . $idgallery . '_' . $filename, 0777);
             @chmod('public/gallery/small/' . $idgallery . '_' . $filename, 0777);
             echo json_encode(array('status' => 'success', 'idgallery' => $idgallery));
             exit;
         } catch (Zend_File_Transfer_Exception $e) {
             echo json_encode(array('status' => 'error', 'msg' => $e->getMessage()));
             exit;
         } catch (Exception $e) {
             echo json_encode(array('status' => 'error', 'msg' => $e->getMessage()));
             exit;
         }
     }
     echo json_encode(array('status' => 'error', 'msg' => 'non-action'));
     exit;
 }