Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function curl($file = null) {
- $save = base_url('assets/backups/backup-on_13-02-2020.sql.zip');
- $cFile = '';
- if (function_exists('curl_file_create')) {
- $cFile = curl_file_create($save);
- } else {
- $cFile = '@' . realpath($save);
- }
- $ch = curl_init();
- curl_setopt($ch, CURLOPT_URL, base_url('backup/curl_rec'));
- // curl_setopt($ch, CURLOPT_HEADER, false);
- curl_setopt( $ch, CURLOPT_HTTPHEADER, array('Content-Type:application/json'));
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
- curl_setopt($ch, CURLOPT_POST, true);
- curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
- curl_setopt($ch, CURLOPT_SAFE_UPLOAD, false);
- curl_setopt($ch, CURLOPT_POSTFIELDS, array(
- 'db' => $cFile
- ));
- $result = curl_exec($ch);
- curl_close($ch);
- $this->output->set_content_type('application/json');
- echo json_encode([$result, $save]);
- }
- function curl_rec() {
- $db['allowed_types'] = '*';
- $db['overwrite'] = TRUE;
- //$config['encrypt_name'] = TRUE;
- //$config['max_width'] = 2000;
- //$config['max_height'] = 2000;
- $db['file_name'] = date('Y-m-d');
- $db['upload_path'] = './assets/';
- $this->load->library('upload', $db);
- if(! $this->upload->do_upload("db")){
- echo $this->upload->display_errors('','');
- }
- if ($this->upload->do_upload("db")) {
- echo $this->upload->data();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement