play freamwork 文件上传

/**
     * 上传
     *
     * @param name
     * @param file
     */
    public static void UploadFile(File file) {

        String fileName = file.getName();

        // 这里存放的是指定的目录data(一般是从配置文件中读取)
        File storeFile = new File("public/images/" + fileName);
        Files.copy(file, storeFile);
        
        String httpUrl=WXConst.FILE_URL;
        String fileType="image";
        String accessToken= Menu.getAccess_token();
        String contentType="JPG";
        String filePath="public/images/";
        
        
        JSON json = new JSONObject();
        json=WXHttpUtil.UploadMedia(httpUrl,fileType,accessToken, fileName, file,contentType, filePath);
        renderText(json.toString());
    }

原文地址:https://www.cnblogs.com/xunfang123/p/4196118.html