-1
I have a system, where monthly files (docx and pdf) are registered, for me to view docx files in the browser I had to use a iframe
, and now I can see the docx, but I can no longer view the PDF...
I was thinking of using a IF
and ELSE
, but I don’t know how to differentiate the files...
To better understand: If the file is DOCX open the file that way, if not, that way...
I redirect the files to the page (see-file.php) to be opened.
Where files are sent:
echo $cont['relatorio_educacao_fisica'] != "" ? "<td><a style='color: Blue' href='ver-arquivo.php?documento=uploads/uploadsed/{$cont['relatorio_educacao_fisica']}' title='{$cont['relatorio_educacao_fisica']}' target='_blank'><img src='images/icon/bola.png' style='width:40px; height:40px;cursor:pointer;'></a></td>" : "<td></td>";
echo $cont['relatorio_enfermagem'] != "" ? "<td><a style='color: Blue' href='ver-arquivo.php?documento=uploads/uploadsenf/{$cont['relatorio_enfermagem']}' title='{$cont['relatorio_enfermagem']}' target='_blank'><img src='images/icon/enf.png' style='width:40px; height:40px;cursor:pointer;'></a></td>" : "<td></td>";
echo $cont['relatorio_nutricao'] != "" ? "<td><a style='color: Blue' href='ver-arquivo.php?documento=uploads/uploadsnut/{$cont['relatorio_nutricao']}' title='{$cont['relatorio_nutricao']}' target='_blank'><img src='images/icon/nut.png' style='width:40px; height:40px;cursor:pointer;'></a></td>" : "<td></td>";
echo $cont['relatorio_pedagogia'] != "" ? "<td><a style='color: Blue' href='ver-arquivo.php?documento=uploads/uploadsped/{$cont['relatorio_pedagogia']}' title='{$cont['relatorio_pedagogia']}' target='_blank'><img src='images/icon/ped.png' style='width:45px; height:45px;cursor:pointer;'></a></td>" : "<td></td>";
echo $cont['relatorio_terapia_ocupacional'] != "" ? "<td><a style='color: Blue' href='ver-arquivo.php?documento=uploads/uploadster/{$cont['relatorio_terapia_ocupacional']}' title='{$cont['relatorio_terapia_ocupacional']}' target='_blank'><img src='images/icon/ter.png' style='width:45px; height:45px;cursor:pointer;'></a></td>" : "<td></td>";
echo $cont['relatorio_servicos_sociais'] != "" ? "<td><a style='color: Blue' href='ver-arquivo.php?documento=uploads/uploadser/{$cont['relatorio_servicos_sociais']}' title='{$cont['relatorio_servicos_sociais']}' target='_blank'><img src='images/icon/ser.png' style='width:45px; height:45px;cursor:pointer;'></a></td>" : "<td></td>";
Code where I view docx files: (view-file.php)
<iframe class="arquivos" src="https://view.officeapps.live.com/op/embed.aspx?src=https://www.meusite.com/<?php echo urlencode($_GET['documento']); ?>"></iframe>
Code of how I was able to view the pdf files:
<a href='uploads/uploadsenf/".$cont['relatorio_enfermagem']."'target='_blank'>".$cont['relatorio_enfermagem']."</a>
Does anyone know how I can do it with IF
and ELSE
, or some other function?
where these files are saved?
– Arthur Luiz
The file path is saved in the database and the files themselves in directory
– user176205
Come on, what I would do is: create a white list containing the allowed extensions and after that use one of the following functions: https://www.php.net/manual/en/function.finfo.php - https://www.php.net/manual/en/function.mime-content-type.php
– Arthur Luiz
I didn’t give you the ready IF code yesterday in chat? This https://pastebin.com/raw/JUrZZfRN
– Guilherme Nascimento
Eai William, it didn’t work, then you had to leave
– user176205