uploadgroupavatar.php 933 B

1234567891011121314151617181920212223242526272829303132
  1. <?php
  2. class file extends control
  3. {
  4. /**
  5. * Upload chat avatar from xuan client.
  6. *
  7. * @access public
  8. * @return void
  9. */
  10. public function uploadGroupAvatar()
  11. {
  12. if($this->app->user->account == 'guest') die;
  13. $file = $this->file->getUpload('imgFile');
  14. $file = current($file);
  15. if($file)
  16. {
  17. move_uploaded_file($file['tmpname'], $this->file->savePath . $this->file->getSaveName($file['pathname']));
  18. /* Compress image for jpg and bmp. */
  19. $file = $this->file->compressImage($file);
  20. $file['addedBy'] = $this->app->user->account;
  21. $file['addedDate'] = helper::now();
  22. unset($file['tmpname']);
  23. $this->dao->insert(TABLE_FILE)->data($file)->exec();
  24. $fileID = $this->dao->lastInsertID();
  25. $this->send(array('result' => 'success', 'id' => $fileID));
  26. }
  27. }
  28. }