[eluser]masentinel900[/eluser]
Hello, In my project I have a dedicated side where the user can to see the files list that is available for download, When the user click on the name of file inmediatelly start the download.
I have all created and works well, The only problem is that wodnload the same file in the differents files.
The process is like this:
1: when the page onload totally create a dinamic table with info from a database.
2: Mainly there are 4 rows.
3: The second row is of "name file" and here there a link for the download of the corresponding file.
4: In the href="" tag of the table, I call the class Download.
The file controller is This:
Code:
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
session_start(); //we need to call PHP's session object to access it through CI
class Download extends CI_Controller
{
public function __construct()
{
parent::__construct();
$this->load->model('content','', TRUE);
}
function index()
{
$query = $this->content->contenido();
foreach($query->result() as $row)
{
$ruta = $row->rutaarchivo;
}
$this->load->helper('download');
$data = file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/Online-App/filesFolder/Actas/" . $ruta);
$name = $ruta;
force_download($name, $data);
}
}
?>
The "$ruta" variable is the name of the file..
All works great, But the only problem is that just download the same file, regardless that the name is other file..
Code:
while($row = pg_fetch_array($seleccion))
{
for($i>0; $i<=$row[idacta]; $i++)
{
echo "
<tr>
<td id='$i'><input name='opcion-res' type='radio' align='center'/></td>
<td id='$i'><a href='download'>$row[descripcion]</a></td>
<td id='$i'>$row[modificadopor]</td>
<td id='$i'>$row[fechademodificacion]</td>
</tr>
";
}
}
I need that each one link download their corresponding file.