Commit f198ff040e67cff9d908d018e9af8bc1ff0bb00c
1 parent
517a6b6b
Exists in
master
Armazenamento da extensão dos arquivos enviados
Showing
2 changed files
with
13 additions
and
9 deletions
Show diff stats
class/solicitacao.class.php
@@ -14,6 +14,8 @@ if (empty($varAreaRestrita)) | @@ -14,6 +14,8 @@ if (empty($varAreaRestrita)) | ||
14 | include_once("../inc/security.php"); | 14 | include_once("../inc/security.php"); |
15 | } | 15 | } |
16 | 16 | ||
17 | +include_once("../inc/funcoes.php"); | ||
18 | + | ||
17 | class Solicitacao { | 19 | class Solicitacao { |
18 | 20 | ||
19 | private $idsolicitacao; | 21 | private $idsolicitacao; |
@@ -857,9 +859,10 @@ class Solicitacao { | @@ -857,9 +859,10 @@ class Solicitacao { | ||
857 | if(!empty($arquivo["tmp_name"])) | 859 | if(!empty($arquivo["tmp_name"])) |
858 | { | 860 | { |
859 | $idmovimentacao = $con->insert_id; | 861 | $idmovimentacao = $con->insert_id; |
860 | - | ||
861 | $dir = getDiretorio("lda")."/"; | 862 | $dir = getDiretorio("lda")."/"; |
862 | - $fullArquivo = "lda_".$idsolicitacao."_mov_".$idmovimentacao; | 863 | + $ext = getExtensaoArquivo($arquivo['name']); |
864 | + | ||
865 | + $fullArquivo = "lda_".$idsolicitacao."_mov_".$idmovimentacao.".".$ext; | ||
863 | 866 | ||
864 | if (!@move_uploaded_file($arquivo["tmp_name"], $dir.$fullArquivo)) | 867 | if (!@move_uploaded_file($arquivo["tmp_name"], $dir.$fullArquivo)) |
865 | { | 868 | { |
@@ -878,11 +881,6 @@ class Solicitacao { | @@ -878,11 +881,6 @@ class Solicitacao { | ||
878 | } | 881 | } |
879 | } | 882 | } |
880 | } | 883 | } |
881 | - | ||
882 | - $ext = getExtensaoArquivo($arquivo['name']); | ||
883 | - | ||
884 | - $fullArquivo = "lda_".$idsolicitacao."_mov_".$idmovimentacao.".".$ext; | ||
885 | - ?> | ||
886 | 884 | ||
887 | //se o status da demanda for "aberto" altera para "em tramitação" | 885 | //se o status da demanda for "aberto" altera para "em tramitação" |
888 | if($status == "A") | 886 | if($status == "A") |
@@ -1096,8 +1094,9 @@ class Solicitacao { | @@ -1096,8 +1094,9 @@ class Solicitacao { | ||
1096 | if ($con->query($sql)) | 1094 | if ($con->query($sql)) |
1097 | { | 1095 | { |
1098 | $idarquivo = $con->insert_id; | 1096 | $idarquivo = $con->insert_id; |
1099 | - | ||
1100 | - $fullArquivo = "lda_".$idsolicitacao."_file_".$idarquivo; | 1097 | + $ext = getExtensaoArquivo($arquivos["name"][$i]); |
1098 | + | ||
1099 | + $fullArquivo = "lda_".$idsolicitacao."_file_".$idarquivo.".".$ext; | ||
1101 | 1100 | ||
1102 | if (!@move_uploaded_file($arquivos["tmp_name"][$i], $dir.$fullArquivo)) | 1101 | if (!@move_uploaded_file($arquivos["tmp_name"][$i], $dir.$fullArquivo)) |
1103 | { | 1102 | { |
restrito/inc/funcoes.php
@@ -187,6 +187,11 @@ function validaTipoArquivo($mime, $extensoes) | @@ -187,6 +187,11 @@ function validaTipoArquivo($mime, $extensoes) | ||
187 | 187 | ||
188 | } | 188 | } |
189 | 189 | ||
190 | +function getExtensaoArquivo($nomearquivo){ | ||
191 | + $aux = explode(".",$nomearquivo); | ||
192 | + return $aux[sizeof($aux)-1]; | ||
193 | + } | ||
194 | + | ||
190 | /* | 195 | /* |
191 | * Smarty plugin | 196 | * Smarty plugin |
192 | * ------------------------------------------------------------- | 197 | * ------------------------------------------------------------- |