Is the File Transfer code correct in my PHP? -


i have page supposed download song. download works in firefox me in chrome , safari nothing happens..here code

    public function download() {     if (isset($this->request->get['order_download_id'])) {         $order_download_id = $this->request->get['order_download_id'];     } else {         $order_download_id = 0;     }     $download_info = $this->db->query("select * " . db_prefix . "order_download od left join `" . db_prefix . "order` o on (od.order_id = o.order_id) o.customer_id = '" . (int)$this->customer->getid(). "' , o.order_status_id > '0' , o.order_status_id = '" . (int)$this->config->get('config_download_status') . "' , od.order_download_id = '" . (int)$order_download_id . "'");      if ($download_info->row) {         $file = dir_download . $download_info->row['filename'];         $mask = basename($download_info->row['mask']);         $mime = 'application/octet-stream';         $encoding = 'binary';          if (!headers_sent()) {             if (file_exists($file)) {                 header('pragma: public');                 header('expires: 0');                 header('content-description: file transfer');                 header('content-type: ' . $mime);                 header('content-transfer-encoding: ' . $encoding);                 header('content-disposition: attachment; filename="' . ($mask ? $mask : basename($file)) . '"');                 header('content-length: ' . filesize($file));                 $file = readfile($file, 'rb');                 print($file);             } else {                 exit('error: not find file ' . $file . '!');             }         } else {             exit('error: headers sent out!');         }     } } 

i have tried kinds of different things work nothing happening in 2 browsers...any ideas or appreciated...

readfile returns number of bytes sent, , needs not printed out. should remove line print($file);. otherwise, you'll send more bytes content-length header specifies, , lead http clients discard answer.

also, consider strange file names such as

"\r\nlocation: http://evil.com\r\n\r\n<script>alert('xss');</script> 

are handling correctly?


Comments

Popular posts from this blog

c# - SharpSVN - How to get the previous revision? -

c++ - Is it possible to compile a VST on linux? -

url - Querystring manipulation of email Address in PHP -