当前位置: 首页>>代码示例>>PHP>>正文


PHP Storage::upload方法代码示例

本文整理汇总了PHP中Storage::upload方法的典型用法代码示例。如果您正苦于以下问题:PHP Storage::upload方法的具体用法?PHP Storage::upload怎么用?PHP Storage::upload使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Storage的用法示例。


在下文中一共展示了Storage::upload方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: store

 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store()
 {
     $validator = Validator::make(Input::all(), Post::$rules);
     if ($validator->fails()) {
         Session::flash('errorMessage', 'Something went wrong here!');
         return Redirect::back()->withErrors($validator)->withInput();
     } else {
         $post = new Post();
         $post->title = Input::get('title');
         $post->body = Input::get('body');
         $post->user_id = Auth::id();
         if (Input::hasFile('picture')) {
             if (Input::file('picture')->isValid()) {
                 Storage::upload(Input::file('picture'), "{$post->picture}" . "jpg");
             }
             $post->picture = Input::file('picture');
         }
         if (Input::has('tags')) {
             $post->tags = implode(', ', Input::get('tags'));
         }
         $post->save();
         $posts = Post::paginate(5);
         Session::flash('goodMessage', 'All went right here!');
         return View::make('posts/index')->with('posts', $posts);
     }
 }
开发者ID:perenchiod,项目名称:Portfolio-Blog,代码行数:31,代码来源:PostsController.php

示例2: pathinfo

    echo "文件不存在";
    // exit;
} else {
    $file = $_FILES["Filedata"];
    if (MAX_FILE_SIZE < $file["size"]) {
        echo "文件已超过限制!";
        exit;
    }
    /*if(!in_array($file["type"], $uptypes))
    //检查文件类型
    {
    echo "文件不是图片格式";
    exit;
    }*/
    $filename = $file["tmp_name"];
    $pinfo = pathinfo($file["name"]);
    $ftype = $pinfo[extension];
    $filenamenew = uniqid(date("Ymd"), true) . "." . $ftype;
    $destination = $destination_folder . $filenamenew;
    //存储
    $stor = new Storage();
    $picurl = $stor->upload(FILE_DIR_TEMP, $destination, $filename);
}
/*echo "dddd";
$mmcache=new MMCache();
$mmcache->getValue("key");

$demo=new Demo();
echo 'aaa';
$demo=new Demo();*/
//return;
开发者ID:xuyintao,项目名称:thindev,代码行数:31,代码来源:test.php

示例3: upFile

 /**
  * 上传文件的主处理方法
  * @param $base64
  * @return mixed
  */
 private function upFile($base64)
 {
     //处理base64上传
     if ($base64) {
         $content = $_POST[$this->fileField];
         $this->base64ToImage($content);
         return;
     }
     //处理普通上传
     $file = $this->file = $_FILES[$this->fileField];
     if (!$file) {
         $this->stateInfo = $this->getStateInfo('POST');
         return;
     }
     if ($this->file['error']) {
         $this->stateInfo = $this->getStateInfo($file['error']);
         return;
     }
     if (!is_uploaded_file($file['tmp_name'])) {
         $this->stateInfo = $this->getStateInfo("UNKNOWN");
         return;
     }
     $this->oriName = $file['name'];
     $this->fileSize = $file['size'];
     $this->fileType = $this->getFileExt();
     if (!$this->checkSize()) {
         $this->stateInfo = $this->getStateInfo("SIZE");
         return;
     }
     if (!$this->checkType()) {
         $this->stateInfo = $this->getStateInfo("TYPE");
         return;
     }
     $this->fullName = $this->getFolder() . '/' . $this->getName();
     if ($this->stateInfo == $this->stateMap[0]) {
         if (!Storage::upload($file["tmp_name"], $this->fullName)) {
             $this->stateInfo = $this->getStateInfo("MOVE");
         } else {
             $this->url = Storage::getUrl($this->fullName);
         }
     }
 }
开发者ID:lunnlew,项目名称:Norma_Code,代码行数:47,代码来源:Uploader.php

示例4: save_to_storage

 /**
  * 通过Storage实现文件保存
  *
  */
 protected function save_to_storage()
 {
     $storage = new Storage($this->config['storage_config']);
     return $storage->upload($this->file['temp'], $this->filename);
 }
开发者ID:xiaodin1,项目名称:myqee,代码行数:9,代码来源:upload.class.php

示例5: update

 /**
  * Update the specified resource in storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function update($id)
 {
     // create the validator
     $validator = Validator::make(Input::all(), Article::$rules);
     // attempt validation
     if ($validator->fails()) {
         return Redirect::back()->withInput()->withErrors($validator);
     } else {
         $article = Article::find($id);
         $article->title = Input::get('title');
         $article->content = Input::get('content');
         // check for img upload
         if (Input::hasFile('photo')) {
             if ($validFile = Input::file('photo')->isValid()) {
                 // delete the old image allowing reuse of file name
                 Storage::delete("{$article->id}-photo");
                 Storage::upload(Input::file('photo'), "{$article->id}-photo");
             } else {
                 return Redirect::back()->withInput()->withErrors($validFile);
             }
         }
         if ($article->save()) {
             Session::flash('successMessage', "Wolfpack Updated: {$article->title}");
             Log::info("Updated article with id: {$id}");
             return Redirect::action('ArticlesController@index');
         } else {
             Session::flash('errorMessage', 'Plz no try to break things.');
             Log::error("Unable to update article with the id: {$id}");
             return Redirect::action('ArticlesController@edit', $id)->withInput()->withErrors($validator);
         }
     }
 }
开发者ID:j-beere,项目名称:laravel-blog,代码行数:38,代码来源:ArticlesController.php


注:本文中的Storage::upload方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。