public function actionIndex($id)
 {
     $model = new ArquivoCrm();
     $file = UploadFile::load($model, 'file');
     if (!empty($file->name)) {
         $name = $this->Formart($file->name);
         $model->name = $name;
         $model->name_alias = $file->name;
         $model->size = $file->size;
         $model->type = $file->type;
         $model->cliente_crm_id = $id;
         $file->saveAs($this->dirName() . $name);
         $model->save();
         $this->Json(['name' => $file->name, 'url' => $this->createUrl('app/assets/arquivos/') . $name, 'delete' => $this->createUrl('painel/arquivos/delete/' . $model->id . '/' . $id)]);
     } else {
         return $this->render('index', ['id' => $id, 'model' => $model, 'dataProvider' => ArquivoCrm::dataProvider($id)]);
     }
 }
 public function actionUpload()
 {
     $model = $this->findModel();
     $file = UploadFile::load($model, 'file');
     if (empty($file)) {
         throw new Exception("Error Processing Request", 401);
     }
     $widimage = WideImage::load($file->tmpName);
     $name = $model->nome . '-' . $model->id . '.' . $file->typeName;
     $resize = $widimage->resize(255, 255);
     //verificando se existe foto
     $fileName = static::dir() . $model->file;
     if (file_exists($fileName)) {
         unlink($fileName);
     }
     $filename = static::dir() . $name;
     $resize->saveToFile($filename);
     $model->file = $name;
     $model->save();
     chmod($filename, 0777);
     Session::setSession(['photo' => $model->file]);
     $this->Json(['files' => [['url' => $this->createUrl() . '/app/assets/arquivos/profile/' . $model->file]]]);
 }
Exemplo n.º 3
0
 public function __construct()
 {
     Kanda::$post = \core\helps\Http::run();
     Kanda::$app = (object) ['arrays' => \core\helps\Arrays::run(), 'cache' => \core\helps\Cache::run(), 'crop' => \core\helps\Crop::run(), 'html' => \core\helps\Html::run(), 'url' => \core\helps\Url::run(), 'uploadFile' => \core\helps\UploadFile::run(), 'session' => \core\helps\Session::run()];
 }
Exemplo n.º 4
0
 public static function dir($name)
 {
     parent::CreateDir(WWW_ROOT . '/images/' . $name);
     parent::CreateDir(WWW_ROOT . '/images/' . $name . '/big');
     parent::CreateDir(WWW_ROOT . '/images/' . $name . '/small');
 }