1,图片上传
2,文件权限
function do_add_gift(){
header("Content-Type: text/html; charset=UTF-8");$data = $this->input->post();
// $id = $data['id'];
$date = date('Ymd');
$datd = date('YmdHis');
$config['upload_path'] = FCPATH.$this->config->item('upload_path').'mall/'."$date/";
if(!file_exists(FCPATH.$this->config->item('upload_path').'mall/'."$date/")){
mkdir(FCPATH.$this->config->item('upload_path').'mall/'."$date/",0777,true);
chmod(FCPATH.$this->config->item('upload_path').'mall/'."$date/",0755);
}
$config['file_name'] = $datd.".jpg";
$config['allowed_types'] = 'gif|jpg|png';
$config['max_size'] = 300;
$config['max_width'] = 400;
$config['max_height'] = 400;
$this->load->library('upload', $config);
if ( !$this->upload->do_upload('userfile')){
$ret['msg'] = $this->upload->display_errors();
jsonpcallback($ret);
}else{
// $id = $data['id'];
$setarr = array();
$setarr['title'] = trim($data['title']);
$setarr['voucher'] = trim($data['voucher']);
$setarr['total'] = trim($data['total']);
$setarr['remain'] = trim($data['total']);
$setarr['description'] = trim($data['description']);
$setarr['status'] = 1;
$setarr['create_time'] = time();
$setarr['operator'] = $this->admin['username'];
$setarr['pic'] = 'mall/'."$date/"."$datd.jpg";
if($this->mall_gift_model->insert($setarr)){
$ret['succ'] = 1;
}else{
$ret['msg'] = '失败';
}
jsonpcallback($ret);
}
}