Example #1
0
 public function upload_file()
 {
     $file_name = $this->sanitize($_SERVER['HTTP_X_FILE_NAME']);
     $file_size = $_SERVER['HTTP_X_FILE_SIZE'];
     $file_type = strtolower($this->findexts($_SERVER['HTTP_X_FILE_NAME']));
     $symbol = $_SERVER['HTTP_X_SYMBOL'];
     $action = $_SERVER['HTTP_X_ACTION'];
     if ($action == 'update') {
         $old_image_name = $_SERVER['HTTP_X_IMAGENAME'];
     }
     $file_ext = explode(",", $this->valid_exts);
     if ($file_size > $this->max_file_size) {
         $this->freichat_debug('file size exceeded');
         $status = 'exceed';
     } else {
         if (!in_array($file_type, $file_ext) && $file_type != 'nofile') {
             $this->freichat_debug('file type invalid');
             $status = 'type';
         } else {
             $ft = new File_Streamer();
             $ft->_fileName = $file_name;
             $ft->setDestination($this->path);
             $ft->receive();
             @chmod($this->path . $file_name, 0777);
             // $this->replace_file($original_name,$file_name);
             $status = $file_name;
             if ($action == 'insert') {
                 $status = $this->insert_smiley($file_name, $symbol);
             } else {
                 $this->update_smiley($file_name, $symbol, $old_image_name, $file_type);
             }
         }
     }
     echo $status;
 }
Example #2
0
 public function upload_file()
 {
     $file_name = $this->sanitize($_SERVER['HTTP_X_FILE_NAME']);
     $file_size = $_SERVER['HTTP_X_FILE_SIZE'];
     $file_type = strtolower($this->findexts($_SERVER['HTTP_X_FILE_NAME']));
     $original_name = $_SERVER['HTTP_X_ORIGINAL_FILE_NAME'];
     $file_ext = explode(",", $this->valid_exts);
     if ($file_size > $this->max_file_size) {
         $this->freichat_debug('file size exceeded');
         $status = 'exceed';
     } else {
         if (!in_array($file_type, $file_ext)) {
             $this->freichat_debug('file type invalid');
             $status = 'type';
         } else {
             $ft = new File_Streamer();
             $ft->_fileName = $file_name;
             $ft->setDestination($this->path . "images/");
             $ft->receive();
             @chmod($this->path . $file_name, 0777);
             $this->replace_file($original_name, $file_name);
             $status = $file_name;
         }
     }
     echo $status;
 }