0
Good afternoon, I have a monthly file registration system, currently the files are displayed through a href redirecting to the file path (directory), giving to download them.
I want to view/open these files without having to download them.
I found a video, and followed, but the page is not responding... VIDEO LINK
Does anyone have any other solution? or tell me where I’m going wrong?
My file: listagem_relatorio_psi.php
<?php
include('menu.php');
?>
<script>
$(document).ready(function () {
$('#dtHorizontalExample').DataTable({
"scrollX": true
});
$('.dataTables_length').addClass('bs-select');
});
</script>
<!-- LISTAGEM -->
<div class="main-content">
<h3><center><i><b> Listagem relatórios psicologia<b></i></center></h3>
<div class="section__content section__content--p30">
<div class="container-fluid">
<div class="row">
<div class="col-lg-12">
<table class="table table-borderless table-striped table-earning" id="dtHorizontalExample" cellspacing="0" width="100%">
<thead>
<th class="th-sm">Paciente
</th>
<th class="th-sm">Janeiro
</th>
<th class="th-sm">Editar
</th>
<th class="th-sm">Excluir
</th>
</tr>
</thead>
</div>
</div>
</div>
</div>
</div>
<tbody>
<?php
require('conexaobd.php');
$sql = "SELECT * FROM relatorio_psi";
$resultado = mysqli_query($link, $sql);
$inc = 0;
while ($cont = mysqli_fetch_array($resultado)) {
echo "
<tr>
<td>".$cont['paciente']."</td>
<td><a href='visualizar_arquivo.php?codigo_relatorio=".$cont['codigo_relatorio']."' target='_blank'><img src='https://cdn4.iconfinder.com/data/icons/free-colorful-icons/360/google_docs.png' style='width:30px; height:30px;cursor:pointer;'></a></td>
<td>
<a href='edit_relatorio_psi.php?codigo_relatorio=".$cont['codigo_relatorio']."&paciente=".$cont['paciente']." target='new_blank'>
<span class='role blue'>
<i class='fa fa-edit'></i>
</span>
</a>
</td>
<td>
<a href='del_relatorio_psi.php?paciente=".$cont['paciente']."' target='new_blank' confirm='Tem certeza que deseja deletar essa internação?'>
<span class='role red'>
<i class='fas fa-trash-alt'></i>
</span>
</a>
</td>
</tr>
</tr>
";
}
?>
My file: visualizar_arquivo.php
<?php
require('conexaobd.php');
$codigo_relatorio = $_GET["codigo_relatorio"];
$result = $conn->query("SELECT * FROM relatorio_psi WHERE codigo_relatorio = $codigo_relatorio");
$query = mysqli_fetch_object($result);
if(mysqli_num_rows($result) > 0){
$pasta = "uploads_psi/".$query->codigo_relatorio;
if (file_exists($pasta)) {
header('Content-Type: application/docx');
header('Content-disposition: inline; filename='.$query->codigo_relatorio);
readfile($pasta);
}else{
echo "Não foi possivel encontrar o arquivo na diretório!";
}
}
?>
Do you receive any error message?
– Kayo Bruno
Shows a
dumpof the variable$query.– Kayo Bruno
Hello @Kayobruno, the page simply does not answer... I am "new" in programming, but I think the part
$query->codigo_relatorio;I’m wrong... I don’t know– user175046