123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263 |
- <?php
- namespace Upload\Lib\Store;
- use Dever;
- class Sina extends Core implements Config
- {
- public $yun = true;
- /**
- * 上传文件
- *
- * @return mixed
- */
- public function save()
- {
- list($yun, $file) = $this->yun();
- $options = array();
- $method = Dever::load('upload/lib/view/sina')->connect($yun, $this->config, $file);
- $ret = $method->upload($file, $this->data['file']['tmp_name'], $options, $this->base64);
- if ($ret) {
- $this->file = $this->output['url'];
- $file = Dever::load('upload/file-name', array('where_name' => $this->name, 'where_upload' => $this->data['key'], 'rand' => time()));
-
- if (isset($file) && $file) {
- $this->update($file['id']);
-
- } else {
- $this->insert();
- }
- return $this->output['url'];
- }
- }
- public function file()
- {
- if ($this->base64 && isset($this->data['local'])) {
- $data = parse_url($this->data['local']);
- $data['path'] = str_replace(Dever::data() . 'upload/', '', $data['path']);
- $this->path = ltrim($data['path'], '/');
- }
- $this->file = $this->path . $this->name . $this->ext;
- $this->output['file'] = $this->file;
- $this->output['url'] = $this->host . $this->file;
-
- //$this->output['url'] = '{uploadYun}' . $this->file;
- return $this->output['file'];
- }
- public function handle_w($water)
- {}
- public function handle_t($id)
- {}
- public function handle_c($id)
- {}
- }
|