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;
 }
Exemple #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();
 }
Exemple #3
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function destroy(Screenshot $screenshot)
 {
     $id = $screenshot->game_id;
     $screenshot->deleteScreenshotFile();
     $screenshot->delete();
     Session::flash('message', 'Screenshot deleted');
     return redirect('/game/' . $id . '/editimages');
 }