Showing posts with label download. Show all posts
Showing posts with label download. Show all posts

Tuesday, May 29, 2018

Download Database Back_up using Codeigniter

//Backup manually
    public function CI_db_backup() {
        // Load the DB utility class
        $this->load->dbutil();
        $this->load->database();
        $dbName = $this->db->database;
        $prefs = array(
            "format" => 'sql', // gzip, zip, txt
            "filename" => $dbName.'.sql', // File name 
        );

// Backup your entire database and assign it to a variable
        $backup = $this->dbutil->backup($prefs);

        $folder = FCPATH . "/storage_db/db_backup/";
        $date = date("m-d-Y-H-i-s", time());
        $filename = $dbName . "_" . $date . ".sql";
// Load the file helper and write the file to your server
        $this->load->helper('file');
        write_file($folder . $filename, $backup);

// Load the download helper and send the file to your desktop
        $this->load->helper("download");
        force_download($filename, $backup);
    }

Saturday, May 12, 2018

Download file using - PHP

            $backup = "Your file data";

            $folder = 'assets/db/';

            if (!is_dir($folder))
                mkdir($folder, 0755, true);

            $date = date('m-d-Y-H-i-s', time());
            $file_name = "filename-" . $date . '.sql';
            $file_url = $folder . $file_name;

            $handle = fopen($file_url, 'w+');

            fwrite($handle, $backup);
            fclose($handle);

            header('Content-Type: application/octet-stream');
            header("Content-Transfer-Encoding: Binary");
            header("Content-disposition: attachment; filename=\"" . $file_name . "\"");
            readfile($file_url);

Product Category Demo in laravel

https://drive.google.com/file/d/1kuyeT3LA22IuN3o_kypOyXesEXMLv31e/view?usp=sharing