文件上传+验证码
来源:互联网 发布:八旗军战斗力 知乎 编辑:程序博客网 时间:2024/06/06 13:24
文件上传:
$config['upload_path'] = './public/uploads/';
$config['allowed_types'] = 'gif|jpg|png';
$config['max_size'] = '1000';
$config['max_width'] = '1024';
$config['max_height'] = '768';
$this->load->library('upload',$config);
$this->upload->do_upload('u_file');
$info = $this->upload->data();
$data['u_file'] = $info['file_name'];
$flag = $this->db->insert("zhou1",$data);
<td><img id='pic' src="<?php echo base_url('public/uploads').'/'.$val['u_file']?>" alt="加载失败" width=50px; height=50px;/></td>
//图片放大放小
$('#pic').click(function(){
var size=parseInt($(this).attr('width'))+20;
var height=parseInt($(this).attr('height'))+20;
$(this).attr('width',size);
$(this).attr('height',height);
})
//缩略图
//图片处理,上传图片
$config['upload_path'] = './Public/uploads/';
$config['allowed_types'] = 'gif|jpg|png';
$config['max_size'] = '2000';
$config['max_width'] = '1024';
$config['max_height'] = '768';
$this->load->library('upload', $config);
if($this->upload->do_upload('img')){
$info=$this->upload->data();
//var_dump($info);exit;
//以原图来生成缩略图
$config1['source_image'] = './Public/uploads/'.$info['file_name'];
$config1['create_thumb'] = TRUE;
$config1['maintain_ratio'] = TRUE;
$config1['width'] = 75;
$config1['height'] = 50;
$this->load->library('image_lib', $config1);
$this->image_lib->resize();
//原图
$data['goods_img']=$info['file_name'];
//缩略图
$data['goods_thumb']=$info['raw_name'].'_thumb'.$info['file_ext'];
//接收数据
$data['goods_sn']=$this->input->post('goods_sn');
$data['goods_name']=$this->input->post('goods_name');
.
.
.
}
//接受原文件图片
$config['upload_path'] = './Public/uploads/thumb/';
$config['allowed_types'] = 'gif|jpg|png';
$config['max_size'] = '200000';
//初始化
$this->upload->initialize($config);
if($this->upload->do_upload('g_img')){
$info=$this->upload->data();
$config['source_image'] = './Public/uploads/thumb/'.$info['file_name'];
$config['create_thumb'] = TRUE;
$config['maintain_ratio'] = TRUE;
$config['width'] = 75;
$config['height'] = 50;
$this->image_lib->initialize($config);
$thumb=$this->image_lib->resize();
$goods=array();
$attr=array();
$goods['g_img']=$info['file_name'];
$goods['g_thumb']=$info['raw_name'].'_thumb'.$info['file_ext'];
验证码:
header("content-type:image/jpeg");
imagejpeg($im);
ImageDestroy($im);
return $word;
<tr>
<td><input type="text" id="codes" placeholder="请输入验证码"/></td>
<td><img src="<?php echo site_url('Welcome/check_code')?>" onclick=this.src="<?php echo site_url('Welcome/check_code').'/'?>"+Math.random()></td>
</tr>
//验证码
public function check_code(){
$code = create_captcha();
$this->session->set_userdata('code',$code);
}
- 文件上传+验证码
- yii中的文件上传以及验证码
- Java文件上传验证
- 前端验证文件上传
- 文件上传验证
- 文件上传验证
- yii 文件上传 验证
- js验证上传文件是否合法
- 验证上传文件的类型
- PHP文件上传基本验证
- 文件的上传和验证码的产生
- 关于Struts上传文件的验证
- 多文件上传类【文件类型严格验证】
- struts2实现文件上传(验证过!)
- 上传文件时JS验证文件类型
- Javascript 验证上传文件的类型
- 关于上传文件验证是否安全
- jsp实现文件上传以及表单验证
- Java程序打包成jar包
- 关于五子棋
- C语言结构体和指针
- [总结]Android 获取本地视频文件路径并播放的几种方式
- C语言结构体数组
- 文件上传+验证码
- Hive表中四种不同数据导出方式以及如何自定义导出列分隔符
- IOI2007 矿工配餐
- 简述JAVA集合框架
- Java 8 Stream 如何还原为集合
- Gentoo Linux安装详解--根据官方WiKi整理
- Installing CUDA 7.5 on CentOS 7 - Unable to locate the kernel source
- 蓝牙协议分析1
- 1分钟彻底理解C语言指针的概念