function changePortraitFormSucceeded(\Nette\Forms\BootstrapUIForm $form) { // TODO peekay support for more types of images or image convertor $membersDb = $this->database->table("users")->where(array("id" => $this->presenter->user->getId())); if ($membersDb->count() > 0) { $uid = $membersDb->fetch()->id; if (file_exists(APP_DIR . '/images/profiles/portrait-' . $uid . '.jpg')) { \App\Model\IO::remove(APP_DIR . '/images/profiles/portrait-' . $uid . '.jpg'); \App\Model\IO::upload(APP_DIR . '/images/profiles/', 'portrait-' . $uid . '.jpg'); } else { \App\Model\IO::upload(APP_DIR . '/images/profiles/', 'portrait-' . $uid . '.jpg'); } } $this->presenter->redirect(":Front:Profile:image"); }
public function editFormSucceeded(\Nette\Forms\BootstrapUIForm $form) { $image = $form->values->the_file->name; $arr = array("title" => $form->values->title, "description" => $form->values->description, "uri" => $form->values->uri, "visible" => $form->values->visible); if ($form->values->the_file->error == 0) { $arr['image'] = $image; if (file_exists(APP_DIR . "/images/carousel/" . $image)) { \App\Model\IO::remove(APP_DIR . "/images/carousel/" . $image); \App\Model\IO::upload(APP_DIR . "/images/carousel/", $image); } else { \App\Model\IO::upload(APP_DIR . "/images/carousel/", $image); } } $this->database->table("carousel")->get($form->values->carousel_id)->update($arr); $this->redirect(this, array("carousel_id" => $form->values->carousel_id)); }