Sina.php 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. <?php
  2. namespace Upload\Lib\Store;
  3. use Dever;
  4. class Sina extends Core implements Config
  5. {
  6. public $yun = true;
  7. /**
  8. * 上传文件
  9. *
  10. * @return mixed
  11. */
  12. public function save()
  13. {
  14. list($yun, $file) = $this->yun();
  15. $options = array();
  16. $method = Dever::load('upload/lib/view/sina')->connect($yun, $this->config, $file);
  17. $ret = $method->upload($file, $this->data['file']['tmp_name'], $options, $this->base64);
  18. if ($ret) {
  19. $this->file = $this->output['url'];
  20. $file = Dever::load('upload/file-name', array('where_name' => $this->name, 'where_upload' => $this->data['key'], 'rand' => time()));
  21. if (isset($file) && $file) {
  22. $this->update($file['id']);
  23. } else {
  24. $this->insert();
  25. }
  26. return $this->output['url'];
  27. }
  28. }
  29. public function file()
  30. {
  31. if ($this->base64 && isset($this->data['local'])) {
  32. $data = parse_url($this->data['local']);
  33. $data['path'] = str_replace(Dever::data() . 'upload/', '', $data['path']);
  34. $this->path = ltrim($data['path'], '/');
  35. }
  36. $this->file = $this->path . $this->name . $this->ext;
  37. $this->output['file'] = $this->file;
  38. $this->output['url'] = $this->host . $this->file;
  39. //$this->output['url'] = '{uploadYun}' . $this->file;
  40. return $this->output['file'];
  41. }
  42. public function handle_w($water)
  43. {}
  44. public function handle_t($id)
  45. {}
  46. public function handle_c($id)
  47. {}
  48. }