|
发表于 2020-2-28 15:49:20
|
显示全部楼层
就这个地址 直接post就好了
- $file = $_FILES['file'];
- if (is_uploaded_file($file['tmp_name'])){
- $arr = pathinfo($file['name']);
- $ext_suffix = $arr['extension'];
- $allow_suffix = array('jpg','gif','jpeg','png');
- if(!in_array($ext_suffix, $allow_suffix)){
- msg(['code'=> 1,'msg'=> '上传格式不支持']);
- }
- $new_filename = time().rand(100,1000).'.'.$ext_suffix;
- if (move_uploaded_file($file['tmp_name'], $new_filename)){
- $data = upload('https://kfupload.alibaba.com/mupload',$new_filename);
- $pattern = '/"url":"(.*?)"/';
- preg_match($pattern, $data, $match);
- @unlink($new_filename);
- if($match && $match[1]!=''){
- msg(['code'=> 0,'msg'=> $match[1]]);
- }else{
- msg(['code'=> 1,'msg'=> '上传失败']);
- }
- }else{
- msg(['code'=> 1,'msg'=> '上传数据有误']);
- }
- }else{
- msg(['code'=> 1,'msg'=> '上传数据有误']);
- }
复制代码 |
|