How can I upload the downloaded file?

I am trying to upload the downloaded file to my database, but I cannot. See below code.

$ filepath = "upload /".$ filename;

   <table class="main_table" border="1">
       <tr class="tb_row">
           <?php
               while($row = mysql_fetch_array($select)){
           ?>
         <td class="tb_dt"><?php echo $row['position']?></td>
         <td class="tb_dt"><?php echo $row['trainings']?></td>
         <td class="tb_dt"><?php echo $row['tr_date']?></td>
        <td><a href="download.php?name=<?php echo $row['img_path'];?>"> download </a></td>
     </tr>
 <?php        }     ?>
 </table>
+4
source share
1 answer

use this

download.php
<?php

  $file= $_GET['name'];// make sure it should be a correct path
  if (file_exists($file)) {
        header('Content-Description: File Transfer');
        header('Content-Type: application/octet-stream');
        header('Content-Disposition: attachment; filename="' . basename($file) . '"');
        header('Expires: 0');
        header('Cache-Control: must-revalidate');
        header('Pragma: public');
        header('Content-Length: ' . filesize($file));
        readfile($file);
        exit;
    }

?>
0
source

Source: https://habr.com/ru/post/1649354/


All Articles