Ejemplo n.º 1
0
 public function postsaveImage()
 {
     $filename;
     $currentImg = $this->request->input('imageurl');
     if ($this->request->has('image_name')) {
         $filename = $this->request->input('image_name') . '.png';
     } else {
         $filename = date("Y-m-d H:i:s") . '.png';
     }
     $img1 = str_replace('data:image/png;base64,', '', $currentImg);
     $path = public_path() . '/screenshots/' . $filename;
     $img = Image::make($img1)->resize(600, null, function ($constraint) {
         $constraint->aspectRatio();
     });
     $img->save($path);
     $imagetosave = new Screenshot();
     $imagetosave->name = $filename;
     $imagetosave->image_path = $path;
     $imagetosave->save();
     return "url path" . $filename;
 }
Ejemplo n.º 2
0
 /**
  * Store a newly created resource in storage.
  *
  * @param  Request  $request
  * @return Response
  */
 public function store(Request $request)
 {
     // Upload screenshot
     $this->validate($request, ['screenshot' => 'required|image']);
     $logged_in_user = Auth::user();
     if ($request->file('screenshot')->isValid()) {
         // We have a file uploaded, and it's valid
         // Store the screenshot
         $screenshot = new Screenshot();
         $screenshot->user_id = $logged_in_user->id;
         $screenshot->extension = $request->file('screenshot')->guessExtension();
         if ($screenshot->save()) {
             // Use ID as file name
             $filename = $screenshot->id . '.' . $request->file('screenshot')->guessExtension();
             // Move the screenshot
             if ($request->file('screenshot')->move(storage_path('uploads/images'), $filename)) {
                 Session::flash('alert-success', 'Screenshot uploaded!.');
             }
         }
     }
     return back();
 }
Ejemplo n.º 3
0
 /**
  * Update the specified resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function update(StoreScreenshotRequest $request, Game $game, Screenshot $screenshot)
 {
     $input = array_except(Input::all(), '_method');
     $screenshot->deleteScreenshotFile();
     $screenshot->update($input);
     $screenshot->game_id = $game->id;
     $screenshot->description = $request->input('description');
     $screenshot->save();
     if ($request->hasFile('filename')) {
         $image = Image::make(Input::file('filename')->getRealPath());
         $screenshot->upload($image);
     }
     Session::flash('message', 'Screenshot upated');
     return redirect('/game/' . $game->id . '/editimages');
 }