本文整理汇总了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);
}
}
示例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;
示例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);
}
}
}
示例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);
}
示例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);
}
}
}