Jenderal92

Untitled

Jul 28th, 2022
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.01 KB | None | 0 0
  1. <?php
  2. namespace App\Http\Controllers;
  3. use Illuminate\Http\Request;
  4. use App\Http\Controllers\Controller;
  5. use Image;
  6. class FileController extends Controller {
  7. public function getResizeImage()
  8. {
  9. return view('files.resizeimage');
  10. }
  11. public function postResizeImage(Request $request)
  12. {
  13. $this->validate($request, [
  14. 'photo' => 'required|image|mimes:jpeg,png,jpg,gif,svg|max:1024',
  15. ]);
  16. $photo = $request->file('photo');
  17. $imagename = time().'.'.$photo->getClientOriginalExtension();
  18.  
  19. $destinationPath = public_path('/thumbnail_images');
  20. $thumb_img = Image::make($photo->getRealPath())->resize(100, 100);
  21. $thumb_img->save($destinationPath.'/'.$imagename,80);
  22.  
  23. $destinationPath = public_path('/normal_images');
  24. $photo->move($destinationPath, $imagename);
  25. return back()
  26. ->with('success','Image Upload successful')
  27. ->with('imagename',$imagename);
  28. }
  29. }
Advertisement
Add Comment
Please, Sign In to add comment