예제 #1
0
 public function uploadAction()
 {
     $this->disableMvc(true, true);
     $account = new Model_Account();
     $adapter = new Zend_File_Transfer_Adapter_Http();
     if (!is_dir(ROOT_PATH . '/public/files/tmp/')) {
         mkdir(ROOT_PATH . '/public/files/tmp/');
     }
     $adapter->setDestination(ROOT_PATH . '/public/files/tmp/');
     $info = $adapter->getFileInfo();
     $ex = explode('.', $info['Filedata']['name']);
     $fileType = $ex[count($ex) - 1];
     $hash = $adapter->getHash('md5');
     $tmpFile = $info['Filedata']['destination'] . '/' . $hash . '.' . $fileType;
     $adapter->addFilter('Rename', array('target' => $tmpFile, 'overwrite' => true));
     if ($adapter->receive()) {
         $img = new Unodor_Image_Resize($tmpFile);
         $img->adaptiveResize(50, 50)->save($tmpFile, false);
         echo $hash . '.' . $fileType;
     }
 }