2011-12-26 78 views
0

我使用的上传库笨上传的图片的最低高度.....笨上传库,以验证最小宽度和图像

$config[‘allowed_types’] = ‘gif|png|jpg’; 
$config[‘max_size’]  = ‘1000’; 
$config[‘max_width’]  = ‘200’; 
$config[‘max_heigth’]  = ‘200’; 
$config[‘upload_path’] = ‘./uploads/’ 
$this->load->library(‘upload’, $config); 

,而用户上传的图片.....用户应上传最低widht和最小高度

该怎么办... ......

CI只有MAX_WIDTH和max_heigth ... ......我知道这个功能以及

getimagesize(); 

,但使用这个功能,我们需要源图像网址...这我没有访问...

+0

上传之前还是之后? – Red 2011-12-26 04:29:37

+0

上传之前... – 2011-12-29 23:44:18

回答

3

要做到这一点使用下一段代码:

$data = $this->upload->data(); 
list($width, $height) = getimagesize($data['full_path']); 

你应该使用JavaScript在上传之前确定文件的大小,因为PHP不能做到这一点,因为它是服务器端而不是客户端。

+0

嗨,感谢您的回答,但这会在上传完成后显示尺寸。上传前需要验证图像。 – 2011-12-29 23:45:10

+0

使用客户端语言,如JavaScript。您应该了解服务器端无法在客户端上测量图像端;) – 2013-06-16 15:18:51

相关问题