source: pro-violet-viettel/www/deploy/20150304/application/modules/ajax/controllers/download.php @ 841

Last change on this file since 841 was 841, checked in by quyenla, 10 years ago
  • Property svn:executable set to *
File size: 1.8 KB
Line 
1<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
2
3
4class Download extends MX_Controller
5{
6
7        public function __construct() {
8                parent::__construct();
9                $user = $this->session->userdata ( 'userInfo' );
10                $this->vservices->setApiUrl($this->config->item('api_url'));
11                $this->vservices->setConnection($this->curl);
12                $this->vservices->setUserId($user['us_id']);
13        }
14       
15        public function getFile () {
16                $file=  $this->input->post('file');
17                $folder=  $this->input->post('folder');
18                $files = $this->vservices->actionExecute('getFiles',array("file"=>$file,"folder"=>$folder));
19                echo "<pre>";
20                print_r($files);
21                echo "</pre>";
22                die();
23                $file = file_get_contents($fileurl); 
24                file_put_contents("1.jpg", $file);
25                $local_file="1.jpg";
26                $download_rate = 512;
27                $download_file = $this->input->post('filename');
28 
29                    // send headers
30    header('Cache-control: private');
31    header('Content-Type: application/octet-stream');
32    header('Content-Length: '.filesize($local_file));
33    header('Content-Disposition: filename='.$download_file);
34 
35    // flush content
36    flush();
37 
38    // open file stream
39    $file = fopen($local_file, "r");
40 
41    while (!feof($file)) {
42 
43        // send the current file part to the browser
44        print fread($file, round($download_rate * 1024));
45 
46        // flush the content to the browser
47        flush();
48 
49        // sleep one second
50        sleep(1);
51    }
52 
53    // close file stream
54    fclose($file);
55   
56                exit;
57           
58        }
59       
60
61}
62
63/* End of file privatecontent.php */
64/* Location: ./application/modules/ajax/controllers/privatecontent.php */
Note: See TracBrowser for help on using the repository browser.