/** * 上传媒体文件. * * @param string $type * @param string $path * @param array $params * * @return string */ protected function upload($type, $path, $params = array()) { if (!file_exists($path) || !is_readable($path)) { throw new Exception("文件不存在或不可读 '{$path}'"); } if (!in_array($type, $this->allowTypes, true)) { throw new Exception("错误的媒体类型 '{$type}'"); } $queries = array('type' => $type, 'agentid' => $this->agentId); $options = array('files' => array('media' => $path)); $url = $this->getUrl($type, $queries); $response = $this->http->post($url, $params, $options); $this->forever = false; if ($type == 'image') { return $response; } $response = Arr::only($response, array('media_id', 'thumb_media_id')); return array_pop($response); }
/** * Remove item form Bag. * * @param string $key */ public function forget($key) { Arr::forget($this->data, $key); }