Commit 6d83c3ea37a376608163ba4adb5a087684efe475

Authored by Caroline Salib
2 parents ed8aec5f f7c0da5c
Exists in master

Merge pull request #139 from ieducativa/add-photo-extension

Alterado upload de foto do aluno para adicionar a extensão da 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
... ...