Exemplo n.º 1
0
 /**
  * 处理上传
  *
  * @access public
  */
 public function process()
 {
     $param = Request::only('authkey', 'args');
     $config = @unserialize(base64url_decode($param['args']));
     $uploadObject = new UploadManager();
     if (!$uploadObject->setParam($config)->checkUploadToken($param['authkey'])) {
         return abort(500);
     }
     $file = Request::file('file');
     $returnFileUrl = $uploadObject->setFile($file)->upload();
     if (!$returnFileUrl) {
         return abort(500);
     }
     $this->saveFile($returnFileUrl, $file);
     return response()->json(['file' => implode('|', $returnFileUrl)]);
 }
Exemplo n.º 2
0
 /**
  * 输出上传图片按钮,调用上传窗口
  */
 public function uploadButton()
 {
     $config = $this->config;
     if (!isset($config['alowexts']) or empty($config['alowexts'])) {
         $config['alowexts'] = 'jpg,jpeg,gif,bmp,png,doc,docx';
     }
     $uploadObject = new UploadManager();
     if (!isset($config['uploadPath']) or empty($config['uploadPath'])) {
         $config['uploadPath'] = Config::get('sys.sys_upload_path') . '/';
     }
     $config['uploadPath'] = base64url_encode($config['uploadPath']);
     $config['uploadUrl'] = route('foundation.upload.index');
     //生成密钥,附止表单被修改。
     $authkey = $uploadObject->setParam($config)->uploadKey();
     return view('admin.widget.uploadbutton', compact('config', 'authkey'));
 }
Exemplo n.º 3
0
 /**
  * 处理上传
  */
 public function process()
 {
     $parpams = Request::only('authkey', 'args');
     $config = @unserialize(base64url_decode($parpams['args']));
     //检测请求是否合法
     $uploadObject = new UploadManager();
     if (!$uploadObject->setParam($config)->checkUploadToken($parpams['authkey'])) {
         return abort(500);
     }
     //开始处理上传
     $file = Request::file('file');
     $returnFileUrl = $uploadObject->setFile($file)->upload();
     if (!$returnFileUrl) {
         return abort(500);
     }
     return response()->json(['file' => $returnFileUrl]);
 }