/site.git/Clientes/Cardif/Site_LuizaSeg/luizaseg_sql/adm-sinistro/include/funcoes/imagens/upload_02.php
https://bitbucket.org/hocarvalho/wroisite · PHP · 428 lines · 289 code · 128 blank · 11 comment · 103 complexity · ff26cc17cb08a4d372b205a1873e7050 MD5 · raw file
- <?php
- require_once 'include/plugins/phpthumb-latest/ThumbLib.inc.php';
-
- if(isset($_FILES['imagem1']) && is_uploaded_file($_FILES['imagem1']['tmp_name'])){
-
- $extension = pega_ext($_FILES['imagem1']['name']);
-
- if($extension==".jpg" ||
- $extension==".JPG" ||
- $extension==".gif" ||
- $extension==".GIF" ||
- $extension==".png" ||
- $extension==".PNG")
- {
-
- $dimensoes = getimagesize($_FILES['imagem1']['tmp_name']);
-
- if($dimensoes[0] >= $largura_img) {
- $error[1] = "A largura da imagem1 é maior ".$largura_img." pixels";
- }
-
- if($dimensoes[1] >= $altura_img) {
- $error[2] = "Altura da imagem1 é maior ".$altura_img." pixels";
- }
-
- if(count($error)!=0) {
- foreach ($error as $erros) {
- $msg=$msg.$erros.".<br /> ";
- }
- }
-
- if($msg!='') {
-
- $dimensao_erro = "<font color=#FF0000><strong>".$msg."</strong></font>";
- $erro=1;
-
- }
- else {
-
- $upload_dir = $diretorio;
- $name_file_1 = $_FILES['imagem1']['name'];
- $name_file_1 = md5(rand()).$extension;
- $file_path = $upload_dir.$name_file_1;
-
- if(!move_uploaded_file($_FILES['imagem1']['tmp_name'], $file_path)) {
-
- $diretorio_erro = "<font color=#FF0000><strong>O Diretório não existe ou tem restrição</strong></font>";
- $erro=1;
-
- }
- else {
-
- $thumb = PhpThumbFactory::create($diretorio.$name_file_1);
- $thumb->resize($largura_thumb, $altura_thumb)->save($diretorio.'/thumb/'.$name_file_1);
-
- }
-
- }
-
- }
- else {
- $extensao_erro = "<font color=#FF0000><strong>Extensão incorreta</strong></font>";
- $erro=1;
- }
-
- }
- else {
-
- //echo "nao tem imagem";
- }
-
- //////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-
- if(isset($_FILES['imagem2']) && is_uploaded_file($_FILES['imagem2']['tmp_name'])){
-
- $extension = pega_ext($_FILES['imagem2']['name']);
-
- if($extension==".jpg" ||
- $extension==".JPG" ||
- $extension==".gif" ||
- $extension==".GIF" ||
- $extension==".png" ||
- $extension==".PNG")
- {
-
- $dimensoes = getimagesize($_FILES['imagem2']['tmp_name']);
-
- if($dimensoes[0] >= $largura_img) {
- $error[1] = "A largura da imagem2 é maior ".$largura_img." pixels";
- }
-
- if($dimensoes[1] >= $altura_img) {
- $error[2] = "Altura da imagem2 é maior ".$altura_img." pixels";
- }
-
- if(count($error)!=0) {
- foreach ($error as $erros) {
- $msg=$msg.$erros.".<br /> ";
- }
- }
-
- if($msg!='') {
-
- $dimensao_erro = "<font color=#FF0000><strong>".$msg."</strong></font>";
- $erro=1;
-
- }
- else {
-
- $upload_dir = $diretorio;
- $name_file_2 = $_FILES['imagem2']['name'];
- $name_file_2 = md5(rand()).$extension;
- $file_path = $upload_dir.$name_file_2;
-
- if(!move_uploaded_file($_FILES['imagem2']['tmp_name'], $file_path)) {
-
- $diretorio_erro = "<font color=#FF0000><strong>O Diretório não existe ou tem restrição</strong></font>";
- $erro=1;
-
- }
- else {
-
- $thumb = PhpThumbFactory::create($diretorio.$name_file_2);
- $thumb->resize($largura_thumb, $altura_thumb)->save($diretorio.'/thumb/'.$name_file_2);
-
- }
-
- }
-
- }
- else {
- $extensao_erro = "<font color=#FF0000><strong>Extensão incorreta</strong></font>";
- $erro=1;
- }
-
- }
- else {
-
- //echo "nao tem imagem3";
- }
-
- //////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-
- if(isset($_FILES['imagem3']) && is_uploaded_file($_FILES['imagem3']['tmp_name'])){
-
- $extension = pega_ext($_FILES['imagem3']['name']);
-
- if($extension==".jpg" ||
- $extension==".JPG" ||
- $extension==".gif" ||
- $extension==".GIF" ||
- $extension==".png" ||
- $extension==".PNG")
- {
-
- $dimensoes = getimagesize($_FILES['imagem3']['tmp_name']);
-
- if($dimensoes[0] >= $largura_img) {
- $error[1] = "A largura da imagem3 é maior ".$largura_img." pixels";
- }
-
- if($dimensoes[1] >= $altura_img) {
- $error[2] = "Altura da imagem3 é maior ".$altura_img." pixels";
- }
-
- if(count($error)!=0) {
- foreach ($error as $erros) {
- $msg=$msg.$erros.".<br /> ";
- }
- }
-
- if($msg!='') {
-
- $dimensao_erro = "<font color=#FF0000><strong>".$msg."</strong></font>";
- $erro=1;
-
- }
- else {
-
- $upload_dir = $diretorio;
- $name_file_3 = $_FILES['imagem3']['name'];
- $name_file_3 = md5(rand()).$extension;
- $file_path = $upload_dir.$name_file_3;
-
- if(!move_uploaded_file($_FILES['imagem3']['tmp_name'], $file_path)) {
-
- $diretorio_erro = "<font color=#FF0000><strong>O Diretório não existe ou tem restrição</strong></font>";
- $erro=1;
-
- }
- else {
-
- $thumb = PhpThumbFactory::create($diretorio.$name_file_3);
- $thumb->resize($largura_thumb, $altura_thumb)->save($diretorio.'/thumb/'.$name_file_3);
-
- }
-
- }
-
- }
- else {
- $extensao_erro = "<font color=#FF0000><strong>Extensão incorreta</strong></font>";
- $erro=1;
- }
-
- }
- else {
-
- //echo "nao tem imagem";
- }
-
- //////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-
- if(isset($_FILES['imagem4']) && is_uploaded_file($_FILES['imagem4']['tmp_name'])){
-
- $extension = pega_ext($_FILES['imagem4']['name']);
-
- if($extension==".jpg" ||
- $extension==".JPG" ||
- $extension==".gif" ||
- $extension==".GIF" ||
- $extension==".png" ||
- $extension==".PNG")
- {
-
- $dimensoes = getimagesize($_FILES['imagem4']['tmp_name']);
-
- if($dimensoes[0] >= $largura_img) {
- $error[1] = "A largura da imagem4 é maior ".$largura_img." pixels";
- }
-
- if($dimensoes[1] >= $altura_img) {
- $error[2] = "Altura da imagem4 é maior ".$altura_img." pixels";
- }
-
- if(count($error)!=0) {
- foreach ($error as $erros) {
- $msg=$msg.$erros.".<br /> ";
- }
- }
-
- if($msg!='') {
-
- $dimensao_erro = "<font color=#FF0000><strong>".$msg."</strong></font>";
- $erro=1;
-
- }
- else {
-
- $upload_dir = $diretorio;
- $name_file_4 = $_FILES['imagem4']['name'];
- $name_file_4 = md5(rand()).$extension;
- $file_path = $upload_dir.$name_file_4;
-
- if(!move_uploaded_file($_FILES['imagem4']['tmp_name'], $file_path)) {
-
- $diretorio_erro = "<font color=#FF0000><strong>O Diretório não existe ou tem restrição</strong></font>";
- $erro=1;
-
- }
- else {
-
- $thumb = PhpThumbFactory::create($diretorio.$name_file_4);
- $thumb->resize($largura_thumb, $altura_thumb)->save($diretorio.'/thumb/'.$name_file_4);
-
- }
-
- }
-
- }
- else {
- $extensao_erro = "<font color=#FF0000><strong>Extensão incorreta</strong></font>";
- $erro=1;
- }
-
- }
- else {
-
- //echo "nao tem imagem";
- }
-
- //////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-
- if(isset($_FILES['imagem5']) && is_uploaded_file($_FILES['imagem5']['tmp_name'])){
-
- $extension = pega_ext($_FILES['imagem5']['name']);
-
- if($extension==".jpg" ||
- $extension==".JPG" ||
- $extension==".gif" ||
- $extension==".GIF" ||
- $extension==".png" ||
- $extension==".PNG")
- {
-
- $dimensoes = getimagesize($_FILES['imagem5']['tmp_name']);
-
- if($dimensoes[0] >= $largura_img) {
- $error[1] = "A largura da imagem5 é maior ".$largura_img." pixels";
- }
-
- if($dimensoes[1] >= $altura_img) {
- $error[2] = "Altura da imagem5 é maior ".$altura_img." pixels";
- }
-
- if(count($error)!=0) {
- foreach ($error as $erros) {
- $msg=$msg.$erros.".<br /> ";
- }
- }
-
- if($msg!='') {
-
- $dimensao_erro = "<font color=#FF0000><strong>".$msg."</strong></font>";
- $erro=1;
-
- }
- else {
-
- $upload_dir = $diretorio;
- $name_file_5 = $_FILES['imagem5']['name'];
- $name_file_5 = md5(rand()).$extension;
- $file_path = $upload_dir.$name_file_5;
-
- if(!move_uploaded_file($_FILES['imagem5']['tmp_name'], $file_path)) {
-
- $diretorio_erro = "<font color=#FF0000><strong>O Diretório não existe ou tem restrição</strong></font>";
- $erro=1;
-
- }
- else {
-
- $thumb = PhpThumbFactory::create($diretorio.$name_file_5);
- $thumb->resize($largura_thumb, $altura_thumb)->save($diretorio.'/thumb/'.$name_file_5);
-
- }
-
- }
-
- }
- else {
- $extensao_erro = "<font color=#FF0000><strong>Extensão incorreta</strong></font>";
- $erro=1;
- }
-
- }
- else {
-
- //echo "nao tem imagem";
- }
-
- //////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-
- if(isset($_FILES['imagem']) && is_uploaded_file($_FILES['imagem']['tmp_name'])){
-
- $extension = pega_ext($_FILES['imagem']['name']);
-
- if($extension==".jpg" ||
- $extension==".JPG" ||
- $extension==".gif" ||
- $extension==".GIF" ||
- $extension==".png" ||
- $extension==".PNG")
- {
-
- $dimensoes = getimagesize($_FILES['imagem']['tmp_name']);
-
- if($dimensoes[0] >= $largura_img) {
- $error[1] = "A largura da imagem é maior ".$largura_img." pixels";
- }
-
- if($dimensoes[1] >= $altura_img) {
- $error[2] = "Altura da imagem é maior ".$altura_img." pixels";
- }
-
- if(count($error)!=0) {
- foreach ($error as $erros) {
- $msg=$msg.$erros.".<br /> ";
- }
- }
-
- if($msg!='') {
-
- $dimensao_erro = "<font color=#FF0000><strong>".$msg."</strong></font>";
- $erro=1;
-
- }
- else {
-
- $upload_dir = $diretorio;
- $name_file_1 = $_FILES['imagem']['name'];
- $name_file_1 = md5(rand()).$extension;
- $file_path = $upload_dir.$name_file_1;
-
- if(!move_uploaded_file($_FILES['imagem']['tmp_name'], $file_path)) {
-
- $diretorio_erro = "<font color=#FF0000><strong>O Diretório não existe ou tem restrição</strong></font>";
- $erro=1;
-
- }
- else {
-
- if($imagem_antiga!='') {
-
- unlink($diretorio.$imagem_antiga);
- unlink($diretorio.'/thumb/'.$imagem_antiga);
-
- }
-
- $thumb = PhpThumbFactory::create($diretorio.$name_file_1);
- $thumb->resize($largura_thumb, $altura_thumb)->save($diretorio.'/thumb/'.$name_file_1);
-
- }
-
- }
-
- }
- else {
- $extensao_erro = "<font color=#FF0000><strong>Extensão incorreta</strong></font>";
- $erro=1;
- }
-
- }
- else {
-
- //echo "nao tem imagem";
- }
- ?>