iconv() [function.iconv]: detected an illegal character in input string
2017-07-25 16:42
483 查看
今天再做一个数据导入,自己新建了一个excel.xlsx然后变更格式为csv,测试不可行,报了题目这个错误。!!!!!需要生成一个csv文件!!!!!结果可行!
data:{iId:tag},
上传文件的时候传递的参数
后台处理
data:{iId:tag},
上传文件的时候传递的参数
<script> function saveCsv(){ var tag = $('#posSelect').val(); $.ajaxFileUpload({ url:'/admmeeting/explore',//用于文件上传的服务器端请求地址 secureuri:false,//一般设置为false fileElementId:'file_upload',//文件上传空间的id属性 <input type="file" id="file" name="file" /> data:{iId:tag}, dataType: 'json',//返回值类型 一般设置为json success: function (data, status) //服务器成功响应处理函数 { if(data.success){ alert('导入成功'); return; }else{ alert(data.msg); } } }) } </script>
后台处理
if(Input::has('iId')){ $iId = trim(intval(Input::get('iId'))); //获取主题的op $oYuzhiDic = RepresentMeetingYuzhi::find($iId); if($oYuzhiDic){ $op = $oYuzhiDic->op; }else{ echo json_encode(array('success'=>false,'msg'=>'该主题不存在')); exit; } }else{ echo json_encode(array('success'=>false,'msg'=>'请选择主题')); exit; } if(Input::hasFile('file_upload')){ setlocale(LC_ALL, 'zh_CN'); ini_set('max_execution_time', '600');//最大执行时间600秒 $file = Input::file('file_upload'); $fileType = strtolower($file->getClientOriginalExtension()); if($fileType=='csv'){ $reName = md5(date('YmdHis')); $file->move(public_path('uploadfile/meetingyuzhi/'),$reName); $fh = fopen(public_path('uploadfile/meetingyuzhi/'.$reName), 'r'); $data = NULL; $insertUser = array(); $data = fgetcsv($fh);//去掉头 $user = array(); //获取所有代表的信息 $oRep = Represent::whereNull('deleted_at')->get(); $aUser = array(); foreach($oRep as $rep){ $aUser[$rep->cwid] = array($rep->id,$rep->name,$rep->region_id,$rep->area_id,$rep->cwid,$op); } while($data = fgetcsv($fh)){ //每次插入1k条数据 $user['uid'] = $aUser[$data[0]][0]; $user['name'] = $aUser[$data[0]][1]; $user['region_id'] =$aUser[$data[0]][2]; $user['area_id'] = $aUser[$data[0]][3]; $user['cwid'] = $aUser[$data[0]][4]; $user['op'] = $aUser[$data[0]][5]; $insertUser[] = $user; if(count($insertUser) == 1000){ try{ DB::table('power_users')->insert($insertUser); }catch(Exception $e){ echo json_encode(array('success'=>false,'msg'=>'部分数据格式不正确,或者已经存在')); exit; } $insertUser = array(); } } } //不足一千的进行操作 try{ if(count($insertUser)>0){ DB::table('power_users')->insert($insertUser); } }catch( b2c3 Exception $e){ echo json_encode(array('success'=>false,'msg'=>'部分数据格式不正确,或者已经存在')); exit; } echo json_encode(array('success'=>true)); }else{ echo json_encode(array('success'=>false,'msg'=>'请选择csv格式文件')); } }else{ echo json_encode(array('success'=>false,'msg'=>'请选择文件')); } }
相关文章推荐
- php iconv() : Detected an illegal character in input string
- iconv() : Detected an illegal character in input string
- php iconv() : Detected an illegal character in input string
- iconv() Detected an illegal character in input string
- mysql phpMyAdmin 导入报错iconv(): Detected an illegal character in input string原因解析
- PHP的iconv()函数遇到的错误: Detected an illegal character in input string ...
- iconv() Detected an illegal character in input string
- php iconv() : Detected an illegal character in input string
- iconv() : Detected an illegal character in input string 报错解决(抄的)
- PHP 读取EXCEL文件出现:Detected illegal character in input string解决
- Notice: iconv() [function.iconv]: Detected an illegal ..问题
- Notice: iconv() [function.iconv]: Detected an illegal ..问题
- PHP错误:iconv() Detected an illegal character
- php iconv() 编码转换出错 Detected an illegal character
- URLDecoder: Illegal hex characters in escape (%) pattern - For input string:
- URLDecoder: Illegal hex characters in escape (%) pattern - For input string:
- Escape 解决中文乱码(URLDecoder: Illegal hex characters in escape (%) pattern - For input string: "u6")
- Search for a string in an infinite stream of input string.
- JNI DETECTED ERROR IN APPLICATION: input is not valid Modified UTF-8: illegal continuation byte 0x3f
- java.lang.IllegalArgumentException: An invalid character [44] was present in the Cookie value