【发布时间】:2016-03-01 07:05:56
【问题描述】:
我需要验证图像的纵横比 (4:3),而不是在 Codeigniter 中验证宽度 (800) 和高度 (600)。
这是我的代码:
public function uploadImage() {
$upload_dir = './media/data/';
$config['upload_path'] = $upload_dir . "800x600";
$config['allowed_types'] = 'jpeg|jpg|png|gif|PNG';
$config['max_size'] = '0';
$config['max_width'] = '800';
$config['min_width'] = '800';
$config['max_height'] = '600';
$config['min_height'] = '600';
$name = time() . '_' . rand(00000000, 99999999);
$config['file_name'] = $name;
$this->load->library('upload', $config);
if (!$this->upload->do_upload('image')) {
$error = array('error' => $this->upload->display_errors());
echo json_encode($error);
} else {
$data = array('upload_data' => $this->upload->data());
$file = $data['upload_data']['full_path'];
$this->ImageResize($file, $upload_dir, $name, $data['upload_data']['file_ext']);
echo json_encode($data);
}
}
【问题讨论】:
标签: php ajax codeigniter