Commit f7c0da5c25d018d53151b1083b84812dc9476ee9
1 parent
23d5cfe8
Exists in
master
Alterado upload de foto do aluno para adicionar a extensão da imagem.
Algumas ferramentas como o php jasper report precisam que o caminho da foto possua a extensão para detectar o tipo de imagem.
Showing
1 changed file
with
15 additions
and
1 deletions
Show diff stats
ieducar/intranet/image_check.php
@@ -76,6 +76,11 @@ class PictureController { | @@ -76,6 +76,11 @@ class PictureController { | ||
76 | function sendPicture($imageName){ | 76 | function sendPicture($imageName){ |
77 | 77 | ||
78 | $this->imageName = $imageName; | 78 | $this->imageName = $imageName; |
79 | + | ||
80 | + if (! $this->hasExtension($this->imageName)) { | ||
81 | + $this->imageName = $this->imageName . '.' . $this->getExtension(); | ||
82 | + } | ||
83 | + | ||
79 | $tmp = $this->imageFile["tmp_name"]; | 84 | $tmp = $this->imageFile["tmp_name"]; |
80 | include('s3_config.php'); | 85 | include('s3_config.php'); |
81 | //Rename image name. | 86 | //Rename image name. |
@@ -147,8 +152,12 @@ class PictureController { | @@ -147,8 +152,12 @@ class PictureController { | ||
147 | } | 152 | } |
148 | 153 | ||
149 | 154 | ||
150 | - function getExtension($name) | 155 | + function getExtension($name) |
151 | { | 156 | { |
157 | + if (is_null($name)) { | ||
158 | + $name = $this->imageFile["name"]; | ||
159 | + } | ||
160 | + | ||
152 | $i = strrpos($name,"."); | 161 | $i = strrpos($name,"."); |
153 | if (!$i) | 162 | if (!$i) |
154 | return ""; | 163 | return ""; |
@@ -157,6 +166,11 @@ class PictureController { | @@ -157,6 +166,11 @@ class PictureController { | ||
157 | 166 | ||
158 | return $ext; | 167 | return $ext; |
159 | } | 168 | } |
169 | + | ||
170 | + function hasExtension($fileName) { | ||
171 | + $lastThreeChars = substr($fileName, -3); | ||
172 | + return in_array($lastThreeChars, $this->suportedExtensions); | ||
173 | + } | ||
160 | } | 174 | } |
161 | 175 | ||
162 | ?> | 176 | ?> |
163 | \ No newline at end of file | 177 | \ No newline at end of file |