add ability to update recipe image
This commit is contained in:
parent
7690615b82
commit
44f8c0e499
@ -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)
|
||||
|
@ -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");
|
||||
|
@ -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 :</label>
|
||||
<input type="file" name="recipeImage" id="recipeImage">
|
||||
|
Loading…
Reference in New Issue
Block a user