add ability to update recipe image

This commit is contained in:
Thomas Rubini 2023-01-26 20:53:32 +01:00
parent 7690615b82
commit 44f8c0e499
No known key found for this signature in database
GPG Key ID: C7D287C8C1CAC373
3 changed files with 16 additions and 1 deletions

View File

@ -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)

View File

@ -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");

View File

@ -27,7 +27,7 @@ if ($O_recipe === null) {
<?php } ?>
<form action="<?= $A_view["POST_URI"] ?>" method="post">
<form action="<?= $A_view["POST_URI"] ?>" method="post" enctype="multipart/form-data">
<label for="recipeImage">Ajoutez l'image de haut de page&nbsp;:</label>
<input type="file" name="recipeImage" id="recipeImage">