Welcome Guest, Not a member yet? Register   Sign In
Force download from memory
#1

[eluser]s.passiatore[/eluser]
Hi to all,

how it's possibile to force download for a file from memory (not from filesystem)?
I've this code but I wan't save file on filesystem...

Code:
$data['risultati'] = $this->LoadResults->load($this->input->post('excl_type'));
$this->load->helper('file');
$name = time();
if (!write_file('temp/' . $name . '.csv', $data['risultati'])) {
   echo 'Unable to write the file';
}
else {
   $this->load->helper('download');
   $datafile = file_get_contents('temp/' . $name . '.csv'); // Read the file's content
   force_download($name . '.csv', $datafile);
}

Thanks a lot!
Stefano
#2

[eluser]mddd[/eluser]
I really don't see the problem here. You already have the data. Just output it.
Why are you saving it to a file and then loading it again? That doesn't make any sense.
Code:
$this->load->helper('download');
$data = $this->LoadResults->load($this->input->post('excl_type'));
force_download('myfilename.csv', $data);
// done.
#3

[eluser]s.passiatore[/eluser]
[quote author="mddd" date="1276617209"]I really don't see the problem here. You already have the data. Just output it.
Why are you saving it to a file and then loading it again? That doesn't make any sense.
Code:
$this->load->helper('download');
$data = $this->LoadResults->load($this->input->post('excl_type'));
force_download('myfilename.csv', $data);
// done.
[/quote]

Ok... it was to easy... sorry!
stefano




Theme © iAndrew 2016 - Forum software by © MyBB