public function uploadLogo($Id = NULL) { if ($Id != NULL) { $partner_model = $this->Partner_model->getById($Id); if ($partner_model != NULL) { $uplPath = $this->config->item('resource_folder') . '/Logo'; $uplConfig['upload_path'] = $uplPath; //$uplConfig['allowed_types'] = $this->config->item('video_allowed_type'); // TODO [hdang.sea] : using specific types is not successfull now $uplConfig['allowed_types'] = '*'; $this->load->library('upload', $uplConfig); if ($this->upload->do_upload('Logo')) { $data = $this->upload->data(); $resource = new Resource_model(); $resource->Path = $uplPath . '/' . $data['file_name']; $resourceId = $resource->save(); $oldResource = $this->Resource_model->getById($partner_model->IdLogo); $partner_model->Path = $resource->Path; $partner_model->IdLogo = $resourceId; $partner_model->save(); $resource->Id = $resourceId; $oldResource->delete($oldResource->Id); echo 1; } } } }
public function uploadBanner($Id = NULL) { if ($Id != NULL) { $banner_model = $this->Banner_model->getById($Id); if ($banner_model != NULL) { $uplPath = $this->config->item('resource_folder') . '/banner'; $uplConfig['upload_path'] = $uplPath; $uplConfig['allowed_types'] = $this->config->item('img_allowed_type'); $uplConfig['max_size'] = $this->config->item('img_max_size'); $uplConfig['max_width'] = $this->config->item('img_max_width'); $uplConfig['max_height'] = $this->config->item('img_max_height'); $this->load->library('upload', $uplConfig); if ($this->upload->do_upload('imgBanner')) { $data = $this->upload->data(); $resource = new Resource_model(); $resource->Path = $uplPath . '/' . $data['file_name']; $resourceId = $resource->save(); $oldResource = $this->Resource_model->getById($banner_model->IdResource); $banner_model->IdResource = $resourceId; $tempId = $banner_model->save(); $oldResource->delete(); echo base_url() . $resource->Path; } } } }
public function uploadVideo($Id = NULL) { if ($Id != NULL) { $video_model = $this->Video_model->getById($Id); if ($video_model != NULL) { $uplPath = $this->config->item('resource_folder') . '/video'; $uplConfig['upload_path'] = $uplPath; //$uplConfig['allowed_types'] = $this->config->item('video_allowed_type'); // TODO [hdang.sea] : using specific types is not successfull now $uplConfig['allowed_types'] = '*'; $this->load->library('upload', $uplConfig); if ($this->upload->do_upload('fileVideo')) { $data = $this->upload->data(); $outputFile = $this->convertVideo($uplPath . '/' . $data['file_name']); if ($outputFile) { $resource = new Resource_model(); $resource->Path = $outputFile; $resourceId = $resource->save(); $oldResource = $this->Resource_model->getById($video_model->IdResource); $video_model->IdResource = $resourceId; $tempId = $video_model->save(); $oldResource->delete(); echo $resourceId; } } } } }
protected function handleEditValidationSuccess($account, $site = '') { if ($account->Id == NULL) { $uplPath = $this->config->item('resource_folder') . '/account'; $uplConfig['upload_path'] = $uplPath; $uplConfig['allowed_types'] = $this->config->item('img_allowed_type'); $uplConfig['max_size'] = $this->config->item('img_max_size'); $uplConfig['max_width'] = $this->config->item('img_max_width'); $uplConfig['max_height'] = $this->config->item('img_max_height'); $this->load->library('upload', $uplConfig); if ($this->upload->do_upload('imgAvatar')) { $data = $this->upload->data(); $resource = new Resource_model(); $resource->Path = $uplPath . '/' . $data['file_name']; $resourceId = $resource->save(); } else { $this->addDataForView($this->getModelVariableName(), $account); $this->addDataForView('err', $this->upload->display_errors('<div>', '</div>')); $this->template->load($this->template_admin, $this->getEditViewName(), $this->getDataForView()); return; } if (isset($resourceId)) { $account->AvatarId = $resourceId; } } parent::handleEditValidationSuccess($account, $site); }
public function uploadDocument($Id = NULL) { if ($Id != NULL) { $videoDocument_model = $this->VideoDocument_model->getById($Id); if ($videoDocument_model != NULL) { $uplPath = $this->config->item('resource_folder') . '/videoDocument'; $uplConfig['upload_path'] = $uplPath; //$uplConfig['allowed_types'] = $this->config->item('video_allowed_type'); // TODO [hdang.sea] : using specific types is not successfull now $uplConfig['allowed_types'] = '*'; $this->load->library('upload', $uplConfig); if ($this->upload->do_upload('fileDocument')) { $data = $this->upload->data(); $resource = new Resource_model(); $resource->Path = $uplPath . '/' . $data['file_name']; $videoDocument_model->FileName = $data['file_name']; $resourceId = $resource->save(); $oldResource = $this->Resource_model->getById($videoDocument_model->IdResource); $videoDocument_model->IdResource = $resourceId; $videoDocument_model->save(); $resource->Id = $resourceId; $query = "SELECT * FROM video_videoDocument where IdVideo=? AND IdDocument=?"; $video_videoDocument = $this->db->query($query, array($oldResource, $videoDocument_model->Id)); if (!isset($video_videoDocument)) { $video_videoDocument->IdDocument = $resourceId; $video_videoDocument->save(); } $oldResource->delete(); echo 1; } } } }