From f7c0da5c25d018d53151b1083b84812dc9476ee9 Mon Sep 17 00:00:00 2001 From: Lucas D'Avila Date: Tue, 14 Jul 2015 17:20:02 -0300 Subject: [PATCH] Alterado upload de foto do aluno para adicionar a extensão da imagem. --- ieducar/intranet/image_check.php | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/ieducar/intranet/image_check.php b/ieducar/intranet/image_check.php index 3983b84..77b28a9 100644 --- a/ieducar/intranet/image_check.php +++ b/ieducar/intranet/image_check.php @@ -76,6 +76,11 @@ class PictureController { function sendPicture($imageName){ $this->imageName = $imageName; + + if (! $this->hasExtension($this->imageName)) { + $this->imageName = $this->imageName . '.' . $this->getExtension(); + } + $tmp = $this->imageFile["tmp_name"]; include('s3_config.php'); //Rename image name. @@ -147,8 +152,12 @@ class PictureController { } - function getExtension($name) + function getExtension($name) { + if (is_null($name)) { + $name = $this->imageFile["name"]; + } + $i = strrpos($name,"."); if (!$i) return ""; @@ -157,6 +166,11 @@ class PictureController { return $ext; } + + function hasExtension($fileName) { + $lastThreeChars = substr($fileName, -3); + return in_array($lastThreeChars, $this->suportedExtensions); + } } ?> \ No newline at end of file -- libgit2 0.21.2