| PHP部分
   
load()->func('file');
$file = $_FILES['file'];
$id=$_GPC['id'];
   
//文件夹路径
$destination_folder = "../attachment/htimg/" . date('Ymd') . "/"; //上传文件路径       
//如果不存在文件夹就创建
if (!file_exists($destination_folder)) {
    mkdir($destination_folder);
}
//创建生成图片的路径        
$destination = $destination_folder . str_shuffle(time() . rand(111, 999)) . $id ."." . "png";
$res=file_upload($file, 'image',$destination);  
$img=$_W['siteroot'].$res['path'];
小程序部分
wx.uploadFile({
  url: url地址, //后台接口
  filePath: tempFilePath,  //文件路径  
  name: 'file',  //随意
  header: { 
       'Content-Type': 'multipart/form-data',
  },
  formData: {
        method: 'POST'   //请求方式
  },
  success(res) {
       console.log(res)
  }
 |