Exemple #1
0
 function changeAvatar()
 {
     if (isset($_POST['avasubmit'])) {
         $upload_dir = './images/avatars/';
         $cfile = md5($_SESSION['nickname']);
         $u = new Uploader();
         try {
             if (is_file($upload_dir . $cfile . '.jpg')) {
                 unlink($upload_dir . $cfile . '.jpg');
             }
             if (is_file($upload_dir . $cfile . '.jpeg')) {
                 unlink($upload_dir . $cfile . '.jpeg');
             }
             if (is_file($upload_dir . $cfile . '.png')) {
                 unlink($upload_dir . $cfile . '.png');
             }
             if (is_file($upload_dir . $cfile . '.gif')) {
                 unlink($upload_dir . $cfile . '.gif');
             }
             $cfile = $u->Upload('avach', $upload_dir, $cfile);
         } catch (Exception $e) {
             $error = $e->getMessage();
         }
         $sql = "UPDATE useravatar SET avatar='" . $cfile . "' WHERE id=(SELECT avatar_id FROM users WHERE id=" . $_SESSION['id'] . ");";
         $this->db->query($sql);
         $_SESSION['avatar'] = $cfile;
     }
 }
Exemple #2
0
 function upload(&$file, $path = 'uploads/', $width = FALSE, $height = FALSE, $ratio = FALSE)
 {
     if ($file['name']) {
         ini_set("max_execution_time", "600");
         ini_set("memory_limit", "12M");
         $this->filename = uniqid();
         $this->load->library('uploader');
         $handle = new Uploader();
         $handle->Upload($file);
         $handle->allowed = array('image/jpeg', 'image/jpg', 'image/gif', 'image/png', 'image/bmp', 'application/pdf');
         $this->handle =& $handle;
         if ($width) {
             return $this->thumb($path, $width, $height, $ratio);
         } else {
             $this->handle->file_new_name_body = $this->filename;
             $this->handle->process($path);
             if ($this->handle->processed) {
                 return $this->handle->file_dst_name;
             }
         }
     }
 }
 /**
  * Crida la funció de pujada del pare
  * i una vegada completat el procés, si l'usuari ho vol
  * redimensiona les imatges pujades. 
  * 
  */
 function Upload()
 {
     $uploaded = parent::Upload();
     if (!$uploaded) {
         echo 'Error upload image';
     } else {
         if ($this->conf['thumb']) {
             $this->createThumbs($uploaded);
         }
     }
     return $uploaded;
 }
 function upload(&$file, $path = 'uploads/', $resize = FALSE, $width = FALSE, $height = FALSE, $ratio = FALSE)
 {
     if ($file['name']) {
         ini_set("max_execution_time", "600");
         ini_set("memory_limit", "12M");
         $this->load->library('uploader');
         $handle = new Uploader();
         $handle->Upload($file);
         $this->handle =& $handle;
         if ($resize) {
             return $this->thumb($path, $width, $height, $ratio);
         } else {
             $this->handle->process($path);
             if ($this->handle->processed) {
                 return $this->handle->file_dst_name;
             }
         }
     }
 }
Exemple #5
0
 function upload(&$file, $path = 'uploads/', $width = FALSE, $height = FALSE, $ratio = FALSE)
 {
     if ($file['name']) {
         ini_set("max_execution_time", "600");
         ini_set("memory_limit", "-1");
         $this->filename = uniqid();
         $this->load->library('uploader');
         $handle = new Uploader();
         $handle->Upload($file);
         $this->handle =& $handle;
         if (!empty($this->watermark['image'])) {
             $this->handle->image_watermark = 'uploads/watermark/' . $this->watermark['image'];
             $this->handle->image_watermark_position = $this->watermark['position'];
         }
         if ($width) {
             return $this->thumb($path, $width, $height, $ratio);
         } else {
             $this->handle->file_new_name_body = $this->filename;
             $this->handle->process($path);
             if ($this->handle->processed) {
                 return $this->handle->file_dst_name;
             }
         }
     }
 }