Advertisement
Sebuahhobi98

curl

Feb 13th, 2020
389
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.38 KB | None | 0 0
  1. function curl($file = null) {
  2. $save = base_url('assets/backups/backup-on_13-02-2020.sql.zip');
  3. $cFile = '';
  4. if (function_exists('curl_file_create')) {
  5. $cFile = curl_file_create($save);
  6. } else {
  7. $cFile = '@' . realpath($save);
  8. }
  9.  
  10. $ch = curl_init();
  11. curl_setopt($ch, CURLOPT_URL, base_url('backup/curl_rec'));
  12. // curl_setopt($ch, CURLOPT_HEADER, false);
  13. curl_setopt( $ch, CURLOPT_HTTPHEADER, array('Content-Type:application/json'));
  14. curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  15. curl_setopt($ch, CURLOPT_POST, true);
  16. curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
  17. curl_setopt($ch, CURLOPT_SAFE_UPLOAD, false);
  18. curl_setopt($ch, CURLOPT_POSTFIELDS, array(
  19. 'db' => $cFile
  20. ));
  21. $result = curl_exec($ch);
  22. curl_close($ch);
  23. $this->output->set_content_type('application/json');
  24. echo json_encode([$result, $save]);
  25. }
  26.  
  27. function curl_rec() {
  28. $db['allowed_types'] = '*';
  29. $db['overwrite'] = TRUE;
  30. //$config['encrypt_name'] = TRUE;
  31. //$config['max_width'] = 2000;
  32. //$config['max_height'] = 2000;
  33. $db['file_name'] = date('Y-m-d');
  34. $db['upload_path'] = './assets/';
  35. $this->load->library('upload', $db);
  36.  
  37. if(! $this->upload->do_upload("db")){
  38. echo $this->upload->display_errors('','');
  39. }
  40.  
  41. if ($this->upload->do_upload("db")) {
  42. echo $this->upload->data();
  43. }
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement