1
A
回答
12
,你可以簡單的使用getImageSize(),因爲這樣
if ($validator->passes() && correct_size(Input::file('file'))) {
// do something
}
list($width, $height) = getimagesize(Input::file('file'));
2
檢查驗證像這樣創建其中一個驗證函數永遠模型,你選擇
public function correct_size($photo) {
$maxHeight = 100;
$maxWidth = 100;
list($width, $height) = getimagesize($photo);
return (($width <= $maxWidth) && ($height <= $maxHeight));
}
可以決定是否要靜態使用它。但是我的建議並不是靜態地定義它,如果你想使用相同的驗證而不依賴於其他上傳。
相關問題
- 1. 上傳前檢查圖像尺寸
- 2. 如何在上傳之前檢索圖像尺寸cloudinary
- 3. 使用PHP上傳圖像前檢查圖像尺寸(高度和寬度)
- 4. 如何上傳圖像縮小尺寸
- 5. flex 4圖像尺寸
- 6. 在上傳時檢查圖像尺寸javascript
- 7. 內存問題檢查圖像尺寸
- 8. 檢查圖像尺寸客戶端
- 9. 限制按尺寸和尺寸上傳無效圖像
- 10. 尺寸偏小圖像上傳
- 11. 大尺寸多圖像上傳asp.net
- 12. 大尺寸多圖像上傳
- 13. 查看上傳的圖片尺寸
- 14. 上傳前用畫布調整圖像尺寸
- 15. 圖像尺寸,
- 16. 檢查圖像大小之前上傳
- 17. iOS視圖控制器尺寸爲iPhone 4上的4英寸
- 18. Laravel 4無法上傳圖像
- 19. 在渲染之前在屏幕尺寸上計算圖像尺寸
- 20. 上傳尺寸PHP
- 21. 尺寸圖像以適合WebView尺寸
- 22. 尺寸圖像的尺寸1600 * 1200
- 23. Mailchimp - 在前景限制圖像尺寸
- 24. 如何在上傳之前檢查圖像大小(例如1MB)
- 25. PHP圖像尺寸
- 26. Carrierwave圖像尺寸
- 27. ImageView圖像尺寸
- 28. UIViewcontroller圖像尺寸
- 29. 如果圖像尺寸較小,則上傳圖像並以瓦片格式顯示容器尺寸
- 30. 檢查相機或圖像的像素尺寸
getimagesize()在這裏工作嗎? – MixedVeg 2014-12-19 03:46:39
你能告訴我更多嗎? – 2014-12-19 03:52:56
哈哈,對不起,去了某地,http://php.net/manual/en/function.getimagesize.php閱讀此:D – MixedVeg 2014-12-19 04:47:13