diff --git a/Controllers/RecipeController.php b/Controllers/RecipeController.php index d589cca..26bdb34 100644 --- a/Controllers/RecipeController.php +++ b/Controllers/RecipeController.php @@ -72,6 +72,11 @@ final class RecipeController $i++; } $O_recipe->S_RECIPE = substr($S_recipe, 2); + + $fp = Utils::tryProcessImg("recipeImage"); + if($fp !== null) { + $O_recipe->updateImg($fp); + } } public function createAction(Array $A_urlParams = null, Array $A_postParams = null) diff --git a/Models/RecipeModel.php b/Models/RecipeModel.php index ffdc71e..2c0e3c3 100644 --- a/Models/RecipeModel.php +++ b/Models/RecipeModel.php @@ -47,6 +47,7 @@ final class RecipeModel $stmt->execute(); $this->I_ID = Model::get()->lastInsertId(); } + public function update() { $O_model = Model::get(); @@ -60,6 +61,15 @@ final class RecipeModel $stmt->bindParam("author_id", $this->I_AUTHOR_ID); $stmt->execute(); } + + public function updateImg($img_fp){ + $O_model = Model::get(); + $stmt = $O_model->prepare("UPDATE RECIPE SET IMG=:img WHERE ID=:id"); + $stmt->bindParam("id", $this->I_ID); + $stmt->bindParam("img", $img_fp, PDO::PARAM_LOB); + $stmt->execute(); + } + public function delete(){ $O_model = Model::get(); $stmt = $O_model->prepare("DELETE FROM RECIPE WHERE ID=:id"); diff --git a/Views/recipe/edit.php b/Views/recipe/edit.php index c5cd745..a9e6cd4 100644 --- a/Views/recipe/edit.php +++ b/Views/recipe/edit.php @@ -27,7 +27,7 @@ if ($O_recipe === null) { -
" method="post"> + " method="post" enctype="multipart/form-data">