Welcome Guest, Not a member yet? Register   Sign In
Download Files Corrupted
#1

[eluser]GabrieleMartino[/eluser]
Hello,

my controller state

public function download_file(){
$this->load->helper('download');

$path = './uploads/'.$this->session->userdata('chat_id').'/files';
$path_complete = $path.'/';
$handle = opendir($path_complete);
$files = glob($path_complete.'*'); // get all file names
foreach($files as $file){ // iterate files
if(is_file($file)Wink{
$data = file_get_contents($file); // Read the file's contents
$name = $file;
force_download($name, $data);

}
}
}

I tried to downloadimages and files. Do not work (corrupted and incomplete).


Thanks
#2

[eluser]GabrieleMartino[/eluser]
I resolved adding

Code:
obclean();

and

Code:
flush();

before

Code:
exit($data);

in the helper.




Theme © iAndrew 2016 - Forum software by © MyBB