$extension = pathinfo($_FILES['files']['name'], PATHINFO_EXTENSION); $uploadFile = $uploadFile . '.' . $extension; $name = $name . '.' . $extension; $anexoItem->setFile($name); $request = mysql_query("SELECT * FROM " . MYSQL_BASE_MEDICAO_ANEXO_ITENS . " WHERE status = 'S' AND nf_recibo = " . $anexoItem->getNfRecibo() . " AND id != " . $anexoItem->getId()); //$num = mysql_num_rows($request); $num = 0; if ($num == 0) { //Fazer o Upload do arquivo if (move_uploaded_file($_FILES['files']['tmp_name'], $uploadFile)) { $arquivo_res = $DAO->Listar("SELECT * FROM " . MYSQL_BASE_MEDICAO_ANEXO_ITENS . " WHERE id = " . $anexoItem->getId()); $nome_arquivo = ""; foreach ($arquivo_res as $row_arquivo) { $nome_arquivo = $row_arquivo['file']; } $Arquivo_res = $DAO->AtualizarArquivoItem($anexoItem); if ($Arquivo_res == false) { unlink("../../arquivos/medicao/" . $anexoItem->getFile()); $msg = utf8_encode("Não foi possivel salvar essa edição, pois o sistema não conseguiu subir o arquivo, favor entrar em contato com a TI."); echo '<script language= "JavaScript">alert("' . $msg . '");</script>'; echo '<script language= "JavaScript">location.href="anexoItem.php?id=' . $anexoItem->getIdAnexo() . '&medicao=' . $anexoItem->getIdMedicao() . '";</script>'; break; } else { if (file_exists("../../arquivos/medicao/" . $nome_arquivo)) { unlink("C:/wamp/www/troncal_SVN/arquivos/medicao/" . $nome_arquivo); } } } else { $msg = utf8_encode("Não foi possivel salvar essa edição, pois o sistema não conseguiu fazer o upload do arquivo, favor entrar em contato com a TI."); echo '<script language= "JavaScript">alert("' . $msg . '");</script>'; }