2 回答

TA貢獻1865條經驗 獲得超7個贊
請在進入愿望文件夾之前使用“調整大小功能”。
use Image;
if (Input::hasFile('title_image')) {
/*$this->validate($request,[
'photo' =>'required|image|mimes:jpg,jpeg,png|max:2048'
]);*/
$Product = Input::file('title_image');
$filename = time() . '.' . $Product->getClientOriginalExtension();
Image::make($Product)->resize(300, 300)->save( public_path('/uploads/avatars/' . $filename) )->move(public_path() . '/../../products', md5($Product->getClientOriginalName()) . ".png");
$product->title_img = "products/" . md5($Product->getClientOriginalName()) . ".png";
}

TA貢獻1934條經驗 獲得超2個贊
如果要縮小或調整圖像大小,可以在上傳圖像之前使用 laravel 圖像壓縮包。這是下面的鏈接,您可以如何做到這一點。 https://www.itsolutionstuff.com/post/laravel-compress-image-before-upload-exampleexample.html
圖像壓縮需要更多,因為當瀏覽器訪問 url 并且該頁面具有超過 10 個圖像時,它首先下載所有圖像并將請求發送到服務器,因為它需要更多時間來加載頁面。所以,get擺脫這個問題使用圖像壓縮包。
- 2 回答
- 0 關注
- 352 瀏覽
添加回答
舉報