【问题标题】:Codeigniter upload library to validate min width and min height of imageCodeigniter 上传库以验证图像的最小宽度和最小高度
【发布时间】:2011-12-26 03:20:04
【问题描述】:

我正在使用 codeigniter 中的上传库来上传图片............

$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);

当用户上传图片时......用户应该上传最小宽度和最小高度

这个怎么办……

CI只有max_width和max_heigth…………我也知道这个功能

 getimagesize();

但要使用此功能,我们需要源图像 url...我无权访问...

【问题讨论】:

  • 上传之前还是之后?

标签: php codeigniter


【解决方案1】:

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

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

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

【讨论】:

  • 您好,感谢您的回答,但这会在上传后给出大小。我需要在上传之前验证图像。
  • 使用客户端语言,例如 javascript。您应该了解服务器端无法在客户端测量图像端;)
猜你喜欢
  • 1970-01-01
  • 2010-12-28
  • 1970-01-01
  • 2017-12-08
  • 1970-01-01
  • 2016-03-30
  • 2016-02-09
  • 2011-12-12
  • 1970-01-01
相关资源
最近更新 更多