php ci框架 上传文件,PHP CI框架批量上传图片

首先说明 我用的是CI框架 1.7.2版本,如果在2.0 和3.0版本请自行测试

//处理上传文件 //$fileNewName 对应数据库 存储图片字段名 //$fileOldName 客户端传来的 图片名 //$fileCount 上传图片多少张 //$orderId  订单编号 function handle_upload_file($fileNewName, $fileOldName, $fileCount, $orderId, $orderTime=0, $fileTime=1){ //var_dump($fileOldName);exit; $orderTime = $orderTime? $orderTime:time(); $this->config->load('upload_conf', true); $config = $this->config->item('file_up_conf', 'upload_conf'); $config['upload_path'] = './file_box/uploads/'.$this->name.'/'.date('Y-m-d', $orderTime).'/'.$orderId; if(!is_dir($config['upload_path'])){ if(!@mkdir($config['upload_path'], 0777, true)){ message_msg('创建图片文件夹失败!'); } } $file = array(); if($fileCount != 1){ for($fileNumber=1; $fileNumber<=$fileCount; $fileNumber++){ $fileOldNameNumber = $fileOldName.$fileNumber; if($_FILES[$fileOldNameNumber]['error'][0] == 0){ //图片大小不能大于500K if($_FILES[$fileOldNameNumber]['size'][0]/1024 <= 500){ $fileInfo = multiples($config['upload_path'], $config, $fileOldNameNumber); if($fileInfo){ $file[$fileNewName.$fileNumber] = serialize($fileInfo[0]['file_name']); } }else{ message_msg('图片尺寸不能大于500K,请重新选择第'.$fileNumber.'张图片!'); } } } if($file && $fileTime){ $file[$fileNewName.'time'] = time(); } }else{ if($_FILES[$fileOldName]['error'][0] == 0){ $fileInfo = multiples($config['upload_path'], $config, $fileOldName); if($fileInfo){ $file[$fileNewName] = serialize($fileInfo[0]['file_name']); } } } return $file; }

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值