Php 如何在laravel 4中上传前检查图像尺寸
我是拉雷维尔4号的新手 我想上传最大尺寸为800x600的照片 请帮助指导我 您可以简单地使用 你可以简单地使用,就像Php 如何在laravel 4中上传前检查图像尺寸,php,laravel,laravel-4,Php,Laravel,Laravel 4,我是拉雷维尔4号的新手 我想上传最大尺寸为800x600的照片 请帮助指导我 您可以简单地使用 你可以简单地使用,就像 像这样检查验证 if ($validator->passes() && correct_size(Input::file('file'))) { // do something } 创建一个这样的验证函数,无论您选择哪个模型 public function correct_size($photo) { $maxHeight = 100;
像这样检查验证
if ($validator->passes() && correct_size(Input::file('file'))) {
// do something
}
创建一个这样的验证函数,无论您选择哪个模型
public function correct_size($photo) {
$maxHeight = 100;
$maxWidth = 100;
list($width, $height) = getimagesize($photo);
return ( ($width <= $maxWidth) && ($height <= $maxHeight) );
}
public函数正确的大小($photo){
$maxHeight=100;
$maxWidth=100;
列表($width,$height)=getimagesize($photo);
返回(($width像这样检查验证
if ($validator->passes() && correct_size(Input::file('file'))) {
// do something
}
创建一个这样的验证函数,无论您选择哪个模型
public function correct_size($photo) {
$maxHeight = 100;
$maxWidth = 100;
list($width, $height) = getimagesize($photo);
return ( ($width <= $maxWidth) && ($height <= $maxHeight) );
}
public函数正确的大小($photo){
$maxHeight=100;
$maxWidth=100;
列表($width,$height)=getimagesize($photo);
return(($width在表单验证中进行如下检查
'avatar' => 'dimensions:min_width=100,min_height=200'
在您的表单验证中进行如下检查
'avatar' => 'dimensions:min_width=100,min_height=200'
getimagesize()在这里工作?你能给我看更多吗?哈哈,对不起去了什么地方,读这个:Dgetimagesize()在这里工作吗?你能给我看更多吗?哈哈,对不起去了什么地方,读这个:D