本文整理匯總了PHP中Images::create方法的典型用法代碼示例。如果您正苦於以下問題:PHP Images::create方法的具體用法?PHP Images::create怎麽用?PHP Images::create使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Images
的用法示例。
在下文中一共展示了Images::create方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: post_upload
public function post_upload($galleryID)
{
$path = path('public') . 'images/' . $galleryID;
Fineuploader::init($path);
$name = Fineuploader::getName();
$fuResponse = Fineuploader::upload($name);
if (isset($fuResponse['success']) && $fuResponse['success'] == true) {
$file = Fineuploader::getUploadName();
Bundle::start('resizer');
$success = Resizer::open($file)->resize(300, 300, 'landscape')->save($path . '/thumbs/' . $name, 90);
Images::create($galleryID, $name);
}
return Response::json($fuResponse);
}
示例2: store
/**
* Store a newly created resource in storage.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public function store(Request $request)
{
$rules = array('album_id' => 'required', 'myimage' => 'required|image');
$validator = Validator::make($request->all(), $rules);
if ($validator->fails()) {
var_dump($validator->errors());
// ->withErrors($validator)
// ->withInput();
}
//$data = $request->only('album_id','myimage');
//$img_data = $this->_dataurlToFile($data['cover_image']);
// $f = finfo_open();
// $extension = finfo_buffer($f, $img_data, FILEINFO_MIME_TYPE);
// $f = finfo_close($f);
// $input = array('cover_image' => $decodedData);
// var_dump($input);
//$file = $request->file('cover_image');
// $random_name = str_random(8);
$destinationPath = 'storage/users/albums/';
//$filename=$random_name.'_cover.png';//.$extension;
$file = $request->file('myimage');
$filename = $file->getClientOriginalName();
$file->move($destinationPath, $filename);
// //$srcPath = $file->getRealPath();
// var_dump($file->move('temp', $filename));
// return;
//Storage::move($data['myimage'],$destinationPath."test.jpg");
// $uploadSuccess = $request->file('cover_image')
// ->move($destinationPath, $filename);
$album = Images::create(array('image' => $filename, 'album_id' => $request->album_id));
return redirect('photos/' . $request->album_id);
//,['id'=>$album->id]
}