E:
/
home
/
kbcomunicacao1
/
Web
/
innterage
/
crm
/
Upload File
HOME
<?php $chave = $_REQUEST["ch"]; $arquivos = $_REQUEST["arquivo"]; $arquivo = utf8_decode($arquivos); $data_atual = date("Y-m-d"); $data_hj = date("d/m/Y"); $hora = date('H:i'); require '../includes/conexao/config.php'; require '../includes/conexao/conn.php'; require '../includes/conexao/function.php'; $query = "SELECT nome_crm, status_crm FROM cw_crm WHERE chavec_crm = '$chave'"; $result = DBExecute($query); $res = mysqli_fetch_assoc($result); $nome_crm = $res['nome_crm']; $status_crm = $res['status_crm']; if($status_crm == 0){ $query = "UPDATE cw_externo SET status_externo = '1' WHERE chave_externo = '$chave'"; $link = DBConnect(); $result = @mysqli_query($link, $query) or die(mysqli_error($link)); $query = "UPDATE cw_crm SET status_crm = '1', lido_crm = '$data_atual', horalido_crm = '$hora', por_crm = '$nome_crm' WHERE chavec_crm = '$chave'"; $link = DBConnect(); $result = @mysqli_query($link, $query) or die(mysqli_error($link)); } if(isset($arquivo) && file_exists($arquivo)){ // faz o teste se a variavel não esta vazia e se o arquivo realmente existe switch(strtolower(substr(strrchr(basename($arquivo),"."),1))){ // verifica a extensão do arquivo para pegar o tipo case "txt": $tipo="application/txt"; break; case "pdf": $tipo="application/pdf"; break; case "exe": $tipo="application/octet-stream"; break; case "zip": $tipo="application/zip"; break; case "doc": $tipo="application/msword"; break; case "docx": $tipo="application/msword"; break; case "xls": $tipo="application/vnd.ms-excel"; break; case "xlsx": $tipo="application/vnd.ms-excel"; break; case "ppt": $tipo="application/vnd.ms-powerpoint"; break; case "gif": $tipo="image/gif"; break; case "png": $tipo="image/png"; break; case "jpg": $tipo="image/jpg"; break; case "mp3": $tipo="audio/mpeg"; break; case "php": // deixar vazio por seurança case "htm": // deixar vazio por seurança case "html": // deixar vazio por seurança } header("Content-Type: ".$tipo); // informa o tipo do arquivo ao navegador header("Content-Length: ".filesize($arquivo)); // informa o tamanho do arquivo ao navegador header("Content-Disposition: attachment; filename=".basename($arquivo)); // informa ao navegador que é tipo anexo e faz abrir a janela de download, tambem informa o nome do arquivo readfile($arquivo); // lê o arquivo exit; // aborta pós-ações }else{ ?> <script language="javascript"> alert("<?php $mensagemexc="Não foi possivél efetuar download. Arquivo excluido."; echo utf8_decode($mensagemexc); ?>"); history.go(-1); </script> <?php } ?>