summaryrefslogtreecommitdiff
path: root/model/Image.php
diff options
context:
space:
mode:
Diffstat (limited to 'model/Image.php')
-rw-r--r--model/Image.php35
1 files changed, 15 insertions, 20 deletions
diff --git a/model/Image.php b/model/Image.php
index d94e95d..4cceb0f 100644
--- a/model/Image.php
+++ b/model/Image.php
@@ -25,32 +25,27 @@ class Image
25 25
26 public function upload() 26 public function upload()
27 { 27 {
28 global $maxWeight;
29
30 // traitement et enregistrement de l'image 28 // traitement et enregistrement de l'image
31 if (isset($_FILES['upload']) AND $_FILES['upload']['error'] == 0) // 0 signifie ok 29 if (isset($_FILES['upload']) AND $_FILES['upload']['error'] == 0) // 0 signifie ok
32 { 30 {
33 if ($_FILES['upload']['size'] <= $maxWeight) 31 $this->pathInfos = pathinfo($_FILES['upload']['name']);
34 { 32 $extension = $this->pathInfos['extension'];
35 $this->pathInfos = pathinfo($_FILES['upload']['name']); 33 $extautorisées = array('jpg', 'jpeg', 'png', 'gif', 'bmp', 'webp', 'tiff');
36 $extension = $this->pathInfos['extension']; 34 // on prend la même liste que celle côté javascript, le SVG est bloqué pour raison de sécurité (javascript à l'intérieur)
37 $extautorisées = array('jpg', 'jpeg', 'png', 'gif', 'bmp', 'webp', 'tiff'); 35 if (in_array($extension, $extautorisées))
38 // on prend la même liste que celle côté javascript, le SVG est bloqué pour raison de sécurité (javascript à l'intérieur) 36 {
39 if (in_array($extension, $extautorisées)) 37 move_uploaded_file($_FILES['upload']['tmp_name'], $this->path . $_FILES['upload']['name']);
40 { 38 chmod($this->path . $_FILES['upload']['name'], 0666);
41 move_uploaded_file($_FILES['upload']['tmp_name'], $this->path . $_FILES['upload']['name']); 39 }
42 chmod($this->path . $_FILES['upload']['name'], 0666); 40 else
43 } 41 {
44 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é';} 42 $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é';
45 } 43 }
46 else
47 {
48 $this->erreur = 'erreur du serveur: le fichier téléchargé est trop lourd, poids max = ' . $maxWeight . ' octets';
49 }
50 } 44 }
51 else 45 else
52 { 46 {
53 $this->erreur = 'erreur du serveur: le fichier téléchargé est trop lourd, poids max = ' . $maxWeight . ' octets'; 47 $this->erreur = 'Erreur: Le fichier n\'a pas pu être téléchargé correctement.<br/>
48 Au fait, "upload_max_filesize" dans le php.ini vaut ' . ini_get('upload_max_filesize') . '.';
54 } 49 }
55 50
56 // retour des rêquetes AJAX 51 // retour des rêquetes AJAX