Guest User

Untitled

a guest
Nov 24th, 2017
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.05 KB | None | 0 0
  1. <?php
  2. if (!defined("BASEPATH")) die(":)");
  3.  
  4. class content extends subcontroller
  5. {
  6.     /**
  7.      * code removed
  8.      *
  9.      */
  10.    
  11.    private function handle_upload()
  12.    {
  13.       $this->load->library("upload");
  14.       $this->upload->initialize($this->config->file_upload);
  15.  
  16.       if (!$this->upload->do_upload())
  17.       {
  18.          throw new general_exception(
  19.             $this->upload->get_error(0),
  20.             http::status_bad_request);
  21.       }
  22.       else
  23.       {
  24.          $result = $this->upload->data();
  25.  
  26.          $filename =
  27.             mb_substr(
  28.                preg_replace(
  29.                   array_keys($this->config->tidy_url_pattern),
  30.                   array_values($this->config->tidy_url_pattern),
  31.                   strtolower($result["raw_name"])),
  32.                0, 64).
  33.                "-".uniqid().
  34.                strtolower($result["file_ext"]);
  35.  
  36.          $newpath = $this->get_file_path($filename);
  37.  
  38.          rename($result["full_path"], $newpath);
  39.          return($filename);
  40.       }
  41.    }
  42.    
  43.     /**
  44.      * code removed
  45.      *
  46.      */
  47.    
  48. }
Add Comment
Please, Sign In to add comment