Create a download link for path that is in mysql

Asked

Viewed 293 times

3

I have the following structure in the database:

reuniaoId   escolaId    usuarioId   dataReuniao tituloReuniao   pathReuniao
7   14  1   2016-01-13  AEQEQ   uploads/reuniao/ata_2016_2418530_2HK73386F.pdf

I need to create a download page of these files

I have the following html code that returns the table and in the download part would need to create a link to be downloaded each file in the "pathReuniao" of <th> "download"

<table> 
            <tr>
             <th> Data </th> 
             <th> Titulo </th>
             <th> Download </th>    
             <th> Remover </th>
            </tr>

            <?php
                while($linha = mysqli_fetch_assoc($lista_amigo )) 
                {
            ?>

            <tr> 
             <td> <?php echo date("d/m/Y", strtotime ($linha["dataReuniao"])) ?> </td>  
             <td> <?php echo utf8_encode($linha["tituloReuniao"]) ?> </td>
             <td> <?php echo utf8_encode($linha["pathReuniao"]) ?> </td>
             <td> <a title="Desativar" href="excluirReuniao.php?codigo=<?php echo $linha["reuniaoId"] ?>"><i class="fa fa-times"></i></a></td>
            </tr>

        <?php
            }
        ?>
  • First, is pathReuniao hosted in apache? If so, just concatenate an http://your server/path in echo.

  • upload/meeting is within the root(www, httpdoc, public_html...) of the website?

1 answer

3


If the files whose pathReunion points are in apache, it is relatively simple to create a hyperlink:

 <td> <?php echo '<a href="http://seuservidor/'.utf8_encode($linha["pathReuniao"]).'">http://seuservidor/'.utf8_encode($linha["pathReuniao"]).'</a>'?> </td>
  • at first are in apache.. but in the future will be on a web server.. would work this way too if I point to the site?

  • exactly, just change the start and can point to where you are.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.