Welcome Guest, Not a member yet? Register   Sign In
Redirect after force download
#1

[eluser]behnampmdg3[/eluser]
Hi

How can I get this redirect to work?

Thanks

Code:
$fp = fopen('file.csv', 'w');
            fputcsv($fp, $template_fields);  
   fclose($fp);
   $this->load->helper('download');
   $name = "template_".$id.".csv";
   $this->load->helper('file');
   $csv_content = read_file('file.csv');
   force_download($name, $csv_content );
   redirect(site_url('edit'), 'refresh');
#2

[eluser]CroNiX[/eluser]
I don't think you can. It wouldn't know when the download is complete so it would just redirect.
#3

[eluser]CroNiX[/eluser]
However, you could probably store the filename in session, redirect and THEN force download on the new page after checking session to see if the filename exists.
#4

[eluser]behnampmdg3[/eluser]
Hi Cronix;

Would you please show with code?

By the way, is Cronix a drug?

Thanks




Theme © iAndrew 2016 - Forum software by © MyBB