[eluser]bazianm[/eluser]
I have a system I am writing. Files uploaded are stored with UUID names and the original name of the file is stored in a field. When the user wants to download the file, the system basically downloads the file as the original name.
This works fine with one exception. When the file has a parenthesis in the name, the download fails.
Here's the controller and the view that is called when the user clicks on the file:
Code:
//Controller
public function docdownload(){
$tidDocument = $this->_uridecode($this->uri->segment(3));
$filename = $this->uri->segment(4);
$mimetype = $this->uri->segment(5);
$fileurl = "files/" . $tidDocument;
$data['filename'] = $filename;
$data['fileurl'] = $fileurl;
$data['mimetype'] = $mimetype;
$this->load->view('modules/doc_download', $data);
}
//View
<?php
$header[0] = "Content-Length: " . filesize ($fileurl);
$header[1] = "Content-type: application/octet-stream";
$header[2] = "Content-disposition: attachment; filename=$filename";
$header[3] = 'Expires: 0';
$header[4] = 'Cache-Control: must-revalidate, post-check=0, pre-check=0';
foreach($header as $line){
header($line);
}
ob_clean();
flush();
readfile($fileurl);
Before anyone asks about the download class, I did try that and had problems with that earlier in development and dropped it. I don't remember why.
Anyway, can anyone give me an idea as to what I need to do here?