ten_file_anh_rong_x_cao
hoa-hong.jpg
, có kích thước thực của file ảnh là 3200x1900 px. Chúng ta sẽ tự sinh ra các file như sau:
hoa-hong.jpg
hoa-hong-100x100.jpg
hoa-hong-150x150.jpg
hoa-hong-300x169.jpg
hoa-hong-450x450.jpg
hoa-hong-600x338.jpg
hoa-hong-768x432.jpg
hoa-hong-1024x576.jpg
composer require intervention/image
config/app.php
return [ ...... ...... $provides => [ ......, Intervention\Image\ImageServiceProvider::class ], $aliases => [ ....., 'Image' => Intervention\Image\Facades\Image::class ] ]
/** * Image resize */ public function imgResize(Request $request) { $image = $request->file('imgFile'); $input['imagename'] = time().'.'.$image->extension(); $filePath = public_path('/thumbnails'); $img = Image::make($image->path()); $img->resize(110, 110, function ($const) { $const->aspectRatio(); })->save($filePath.'/'.$input['imagename']); $filePath = public_path('/images'); $image->move($filePath, $input['imagename']); return back() ->with('success','Image uploaded') ->with('fileName',$input['imagename']); }
Thực hiện các bước tuần tự theo nội dung Bài học nhé!
Cùng nhau học tập, khám phá các kiến thức nền tảng về Lập trình web, mobile, database nhé.
Nền tảng kiến thức - Hành trang tới tương lai hân hạnh phục vụ Quý khách!
Khám phá, trải nghiệm ngay
Vui lòng đăng nhập để gởi bình luận!
Đăng nhậpChưa có bình luận nào!