summaryrefslogtreecommitdiff
path: root/model/Image.php
diff options
context:
space:
mode:
Diffstat (limited to 'model/Image.php')
-rw-r--r--model/Image.php16
1 files changed, 9 insertions, 7 deletions
diff --git a/model/Image.php b/model/Image.php
index efd75cc..51d2fa4 100644
--- a/model/Image.php
+++ b/model/Image.php
@@ -3,10 +3,10 @@
3 3
4class Image 4class Image
5{ 5{
6 private const MAX_WEIGHT = 2000000; // taille max des images (par défaut 2Mo dans php.ini) 6 private const MAX_WEIGHT = 2000000; // à adapter au php.ini
7 private $page; 7 private $page;
8 private $ajax = false; 8 private $ajax = false; // vaut true avec le ckeditor
9 public $erreur = ''; 9 public $erreur;
10 10
11 public function __construct($ajax) 11 public function __construct($ajax)
12 { 12 {
@@ -37,19 +37,21 @@ class Image
37 } 37 }
38 else{$this->erreur = 'mauvais format, veuillez utiliser une image comportant un de ces formats: jpg ou jpeg, png, gif, bmp, webp, tiff<br />le format svg n\'est pas supporté';} 38 else{$this->erreur = 'mauvais format, veuillez utiliser une image comportant un de ces formats: jpg ou jpeg, png, gif, bmp, webp, tiff<br />le format svg n\'est pas supporté';}
39 } 39 }
40 else{$this->erreur = 'fichier trop lourd';} 40 else
41 {
42 $this->erreur = 'erreur du serveur: le fichier téléchargé est trop lourd, poids max = ' . self::MAX_WEIGHT . ' octets';
43 }
41 } 44 }
42 else 45 else
43 { 46 {
44 $this->erreur = $_FILES['upload']['error']; 47 $this->erreur = 'erreur du serveur: le fichier téléchargé est trop lourd, poids max = ' . self::MAX_WEIGHT . ' octets';
45 } 48 }
46 49
47 // retour des rêquetes AJAX 50 // retour des rêquetes AJAX
48 if($this->ajax) 51 if($this->ajax && empty($Image->erreur))
49 { 52 {
50 // nouveau chemin à renvoyer en format json 53 // nouveau chemin à renvoyer en format json
51 $chemin = '{"url": "data/' . $this->page . '/images/' . $_FILES['upload']['name'] . '"}'; 54 $chemin = '{"url": "data/' . $this->page . '/images/' . $_FILES['upload']['name'] . '"}';
52 //echo json_encode($chemin);
53 echo $chemin; 55 echo $chemin;
54 } 56 }
55 } 57 }