Welcome Guest, Not a member yet? Register   Sign In
force_download problem
#3

[eluser]Mhabub[/eluser]
Here is the code:

$file_path = 'csv_data/';
$csv_file_name = 'ogsi_'.date("Y-m-d_h-i-m").'.csv';

//chmod($file_path."/".$csv_file_name, 0777);

$fp = fopen($file_path.$csv_file_name, 'w');

$result_array = array();
$result_array[0] = "Date,Granular Totes,Granular Bags,Pellet Totes,Pellet Bags,Total Tons,Manhours,Tons/Manhour";
$i = 1;
foreach ($csv_record->result() as $rec){
$result_array[$i]=$rec->creation_date.','.$rec->granular_totes.','.$rec->granular_gags.','.$rec->pellet_totes.','.$rec->pellet_bags.','.$rec->total_tons.','.$rec->manhours.','.$rec->tons_by_manhour;
$i++;
}

foreach($result_array as $line_data){
fputcsv($fp, split(',', $line_data));
}
fclose($fp);


$this->load->helper('download');
$doc_file_name = $csv_file_name;
$doc_file_loc = file_get_contents($this->baseurl.'csv_data/'.$csv_file_name); // Read the file's contents
force_download($doc_file_name,$doc_file_loc);


Messages In This Thread
force_download problem - by El Forum - 04-04-2010, 11:06 PM
force_download problem - by El Forum - 04-04-2010, 11:08 PM
force_download problem - by El Forum - 04-04-2010, 11:10 PM
force_download problem - by El Forum - 04-04-2010, 11:23 PM
force_download problem - by El Forum - 04-04-2010, 11:36 PM
force_download problem - by El Forum - 04-04-2010, 11:38 PM



Theme © iAndrew 2016 - Forum software by © MyBB