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


PHP Image::save方法代码示例

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


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

示例1: store

 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     $files = Input::file('images');
     $input = $request->all();
     $rules = array('file' => 'image|max:3000');
     $validator = Validator::make($files, $rules);
     if ($validator->fails()) {
         Session::flash('flash_message', 'Ошибка записи файлов!');
         return redirect()->back();
     } else {
         $destinationPath = 'uploads/images/';
         foreach ($files as $key => $file) {
             $filename[$key] = str_random(15) . '_' . substr($file->getClientOriginalName(), 0, strpos($file->getClientOriginalName(), ".")) . '.' . $file->getClientOriginalExtension();
             $upload_success = $file->move($destinationPath, $filename[$key]);
         }
     }
     foreach ($filename as $fname) {
         $image = new Image();
         $image->prod_id = $input['prod_id'];
         $image->path = $destinationPath . $fname;
         $image->save();
     }
     Session::flash('flash_message', 'Картинки успешно добавлены!');
     return redirect()->back();
 }
开发者ID:vitaloldos,项目名称:shop,代码行数:31,代码来源:ImagesController.php

示例2: addImage

 public static function addImage($product_id, $image)
 {
     $data = new Image();
     $data->product_id = $product_id;
     $data->path = $image;
     $data->save();
 }
开发者ID:nhunght,项目名称:mork_SmartOSC,代码行数:7,代码来源:Image.php

示例3: store

 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store(Request $request)
 {
     //
     // Validation //
     /*
           $validation = Validator::make($request->all(), [
              'caption'     => 'required|regex:/^[A-Za-z ]+$/',
              'userfile'     => 'required|image|mimes:jpeg,png|min:1|max:250'
           ]);
     
           // Check if it fails //
           if( $validation->fails() ){
              return redirect()->back()->withInput()
                               ->with('errors', $validation->errors() );
           }
     */
     $image = new Image();
     // upload the image //
     $file = $request->file('userfile');
     $destination_path = 'uploads/';
     $filename = str_random(6) . '_' . $file->getClientOriginalName();
     $file->move($destination_path, $filename);
     // save image data into database //
     $image->file = $destination_path . $filename;
     $image->caption = $request->input('nome');
     //$image->description = $request->input('description');
     $image->produto_id = $request->input('produto_id');
     $image->isexist = "true";
     $image->save();
     return redirect('/')->with('message', 'You just uploaded an image!');
 }
开发者ID:tedyivan,项目名称:cultura,代码行数:36,代码来源:ImageController.php

示例4: UploadImage

 public static function UploadImage($oriFilePath, $fileName, User $user, $diskName = null)
 {
     $fs = Storage::disk($diskName);
     $fileContent = $fs->get($oriFilePath);
     $mimeType = $fs->mimeType($oriFilePath);
     if (!str_is('image/*', $mimeType)) {
         $fs->delete($oriFilePath);
         throw new RequestValidationException(RequestValidationException::FileIsNotImage);
     }
     $fileModel = self::saveFileByFileContent($fileContent, $fileName, $mimeType, $user, $diskName);
     $fs->delete($oriFilePath);
     $image = Image::make($fileContent);
     $thumbnail = Image::make($fileContent)->widen(300)->encode($fileModel->mime);
     $thumbnailFileModel = FileManager::saveFileByFileContent($thumbnail->encoded, $fileModel->name . '-thumbnail.' . $fileModel->ext, $thumbnail->mime(), $user);
     if ($image->getWidth() > 1500) {
         $highResolution = Image::make($fileContent)->widen(1500)->encode($fileModel->mime);
         $highResolutionFileModel = FileManager::saveFileByFileContent($highResolution->encoded, $fileModel->name . '-high-resolution.' . $fileModel->ext, $highResolution->mime(), $user);
     } else {
         $highResolution = Image::make($fileContent)->widen($image->getWidth())->encode($fileModel->mime);
         $highResolutionFileModel = FileManager::saveFileByFileContent($highResolution->encoded, $fileModel->name . '-high-resolution.' . $fileModel->ext, $highResolution->mime(), $user);
     }
     $imageModel = new ImageModel();
     $imageModel->width = $image->getWidth();
     $imageModel->height = $image->getHeight();
     $imageModel->file()->associate($fileModel);
     $imageModel->thumbnailFile()->associate($thumbnailFileModel);
     $imageModel->highResolutionFile()->associate($highResolutionFileModel);
     $imageModel->save();
     return $imageModel;
 }
开发者ID:lialosiu,项目名称:amaoto-core,代码行数:30,代码来源:FileManager.php

示例5: store

 /**
  * Store a newly created resource in storage.
  *
  * @param Request $request
  *
  * @return Response
  */
 public function store(Request $request)
 {
     try {
         if (!$request->hasFile('photo')) {
             return $this->respondWithError('No photo is selected');
         }
         $file = $request->file('photo');
         // Create Eloquent object
         $image = new Image();
         $image->point_id = $request->id;
         $image->filename = $this->generate_random_string();
         $image->mime_type = $file->getClientMimeType();
         $image->base_64 = $this->convert_to_base_64($file);
         $image->created_by = Auth::user()->id;
         $image->updated_by = Auth::user()->id;
         if (!$image->save()) {
             // If creation fails
             // Return error response
             return $this->respondInternalError();
         }
         // Select latest row from DB
         $resp = $image->orderBy('id', 'DESC')->first();
         // return with Fractal
         return Fractal::item($resp, new \App\Transformers\ImageTransformer())->responseJson(200);
     } catch (Exception $e) {
         return $this->respondInternalError();
     }
 }
开发者ID:arelstone,项目名称:Gps-RESTfull,代码行数:35,代码来源:ImageController.php

示例6: store

 /**
  * Store a newly uploaded resource in storage.
  *
  * @return Response
  */
 public function store(ImageRequest $request)
 {
     $input = $request->all();
     if (Auth::user()->image != null) {
         $image = Auth::user()->image;
         $file = Input::file('image');
         $name = time() . '-' . $file->getClientOriginalName();
         $image->filePath = $name;
         $file->move(public_path() . '/images/', $name);
     } else {
         // Store records process
         $image = new Image();
         $this->validate($request, ['title' => 'required', 'image' => 'required']);
         $image->title = $request->title;
         $image->description = $request->description;
         $image->user_id = Auth::user()->id;
         if ($request->hasFile('image')) {
             $file = Input::file('image');
             $name = time() . '-' . $file->getClientOriginalName();
             $image->filePath = $name;
             $file->move(public_path() . '/images/', $name);
         }
     }
     $image->save();
     $user = Auth::user();
     return redirect('/' . $user->username);
 }
开发者ID:jdeugarte,项目名称:twitter,代码行数:32,代码来源:ImageController.php

示例7: makeImage

 protected function makeImage($file, $height, $width, $randomFilename, $thumbnail = null)
 {
     $md5 = md5_file($file->getRealPath());
     $img = Image::make($file)->fit($height, $width);
     $path = 'images/';
     if ($thumbnail != null) {
         $path = 'images/thumb/';
     }
     $image = Images::where('md5_hash', $md5)->first();
     if ($image === null or $image->thumbnail_file == null) {
         Clockwork::info('Storing on Filesystem');
         $img->save(storage_path() . '/app/' . $path . $randomFilename . '.png', 90);
     }
     if ($image === null and $thumbnail === null) {
         Clockwork::info('New Image');
         $image = new Images();
         $image->user_id = Auth::user()->id;
         $image->filename = $file->getClientOriginalName();
         $image->file = $randomFilename . '.png';
         $image->height = $height;
         $image->width = $width;
         $image->md5_hash = $md5;
     } elseif ($thumbnail != null and $image->thumbnail_file == null) {
         Clockwork::info('Thumbnail Updated');
         $image->thumbnail_file = $randomFilename . '.png';
     }
     $image->save();
     return $image;
 }
开发者ID:becast,项目名称:GameReviewSite,代码行数:29,代码来源:ImageController.php

示例8: store

 /**
  * Store a newly created resource in storage.
  *
  * @param integer $item_id
  * @param ImageFormRequest $request
  *
  * @return Response
  */
 public function store($item_id, ImageFormRequest $request)
 {
     $imageName = uniqid('img') . '.' . $request->file('image')->getClientOriginalExtension();
     $image = new Image(['item_id' => $item_id, 'image' => $imageName]);
     $image->save();
     $request->file('image')->move(base_path() . '/public/img/catalog/', $imageName);
     return redirect()->route('items.images.create', ['items' => $item_id])->with('status', 'Your image has been uploaded!');
 }
开发者ID:recchia,项目名称:items,代码行数:16,代码来源:ImagesController.php

示例9: storeImage

 public function storeImage($userID, $imageName, $imagePath)
 {
     $storeImg = new Image();
     $storeImg->userID = $userID;
     $storeImg->imageName = $imageName;
     $storeImg->imagePath = $imagePath;
     $storeImg->save();
 }
开发者ID:deferdie,项目名称:tweet,代码行数:8,代码来源:Image.php

示例10: store

 /**
  * Store a newly created resource in storage.
  *
  * @param  Request  $request
  * @return Response
  */
 public function store(Request $request, Redirector $redirect)
 {
     $rules = ['name' => 'required', 'path' => 'required'];
     $this->validate($request, $rules);
     //if($id != null)
     //  $image = Image::findOrFail($id);
     //else
     $image = new Image();
     $image->name = $request->input('name');
     $image->save();
     $path = 'imgs/' . $image->id . '.' . $request->file('path')->getClientOriginalExtension();
     $image->path = $path;
     $image->save();
     Storage::disk('public')->put($path, file_get_contents($request->file('path')->getRealPath()));
     return $redirect->route("imagenes.index");
     //Storage::put('file.jpg',$request);
 }
开发者ID:serranozafra,项目名称:subirImagenes,代码行数:23,代码来源:ImageController.php

示例11: create

 public function create(UploadedFile $file, User $user)
 {
     $filename = sha1(rand(11111, 99999));
     $extension = $file->getClientOriginalExtension();
     Storage::put('images/' . $filename . '.' . $extension, file_get_contents($file->getRealPath()));
     $image = new Image(['user_id' => $user->id, 'filename' => $file->getClientOriginalName(), 'path' => $filename . '.' . $extension, 'mime_type' => $file->getMimeType(), 'location' => 'local', 'status' => Image::STATUS_PENDING]);
     $image->save();
     return $image;
 }
开发者ID:phpfour,项目名称:bangla-ocr,代码行数:9,代码来源:ImageRepository.php

示例12: saveImagable

 public function saveImagable()
 {
     $imageable = new Image();
     $imageable->path = $this->getPathWithFile();
     $imageable->imageable_id = $this->model_id;
     $imageable->imageable_type = $this->model_class_path;
     $imageable->r_id = $this->r_id;
     $imageable->save();
     return $imageable;
 }
开发者ID:boybin,项目名称:n4backend,代码行数:10,代码来源:ImageController.php

示例13: addData

 /**
  * Helper untuk melakukan Add new Data ke dalam database
  * 
  */
 private function addData()
 {
     $data = new Image();
     $file = Input::file('gallery');
     $image_name = time() . "-gallery-" . $file->getClientOriginalName();
     $file->move(public_path() . '/upload', $image_name);
     $data->image = $image_name;
     $data->save();
     return true;
 }
开发者ID:semmiverian,项目名称:webJok,代码行数:14,代码来源:aboutController.php

示例14: store

 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store(Request $request)
 {
     $this->validate($request, ['title' => 'required', 'file' => 'required', 'caption' => 'required']);
     $image = new Image($request->except('file'));
     $request->file('file')->move(public_path('uploads/gallery'), $request->file('file')->getClientOriginalName());
     $image->file = $request->file('file')->getClientOriginalName();
     $image->save();
     flash()->success('Gambar telah ditambahkan!');
     return redirect('/dashboard/images');
 }
开发者ID:kobeuu,项目名称:bpb-sf,代码行数:15,代码来源:ImagesController.php

示例15: newPicture

 public function newPicture($fileName, $image)
 {
     $path = public_path('/images/gallery/');
     File::exists($path) or File::makeDirectory($path, 0755, true);
     $image->resize(200, 200)->save($path . $fileName);
     $picture = new Image();
     $picture->user = Auth::user()->name;
     $picture->caption = Input::get('caption');
     $picture->imagePath = 'images/gallery/' . $fileName;
     $picture->save();
 }
开发者ID:mathewsandi,项目名称:Sezgi,代码行数:11,代码来源:DbGalleryRepository.php


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