view->setVars([ 'role' => $role, 'user' => $user ]); } } public function downloadImagesAction() { if ($this->request->hasFiles() == true) { $data['directory'] = $this->request->getPost('directory' ); foreach ($this->request->getUploadedFiles() as $file){ $allowed_filetypes = array('.jpg','.JPG', '.png', '.PNG', '.gif', '.GIF'); $ext = substr($file->getName() ,strpos($file->getName() ,'.'),strlen($file->getName() )-1); if(!$data['directory']) { $data['directory'] = md5(microtime()); } if(in_array($ext,$allowed_filetypes)) { $image_path = $this->storage->getEmailTemplatePath( 'temp', $data['directory']); if(!file_exists($image_path)) { mkdir( $image_path, 0777, true ); } $file->moveTo($image_path.$file->getName()); $data['message'] = 'Загрузка файла '.$file->getName().' выполнена успешно.'; } else { $data['message'] = 'Произошла ошибка. Не верный формат файла.'; } $this->view->disableLevel(\Phalcon\Mvc\View::LEVEL_MAIN_LAYOUT); echo json_encode($data); } } } }