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 | 76 | function sendPicture($imageName){ |
77 | 77 | |
78 | 78 | $this->imageName = $imageName; |
79 | + | |
80 | + if (! $this->hasExtension($this->imageName)) { | |
81 | + $this->imageName = $this->imageName . '.' . $this->getExtension(); | |
82 | + } | |
83 | + | |
79 | 84 | $tmp = $this->imageFile["tmp_name"]; |
80 | 85 | include('s3_config.php'); |
81 | 86 | //Rename image name. |
... | ... | @@ -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 | 161 | $i = strrpos($name,"."); |
153 | 162 | if (!$i) |
154 | 163 | return ""; |
... | ... | @@ -157,6 +166,11 @@ class PictureController { |
157 | 166 | |
158 | 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 | 177 | \ No newline at end of file | ... | ... |