📜  使用 formdata 上传图片 - 任何代码示例

📅  最后修改于: 2022-03-11 14:59:50.277000             🧑  作者: Mango

代码示例1
export async function newDocUpload(
    access_token: string,
    question_id: any,
    upload_type:any,
    file:any,
    type:any,
    id:any,
) {
  const url = `${server_url}/rm/upload/doc/`;
  const formdata = new FormData()
  formdata.append('question_id',question_id);
  formdata.append('upload_type',upload_type);
  formdata.append('new_document_file',file);
  formdata.append('type',type);
  formdata.append('id',id);
    try {
    const response = await axios({
        method: "post",
        url: url,
        data:formdata,
        headers: {
            Authorization: `Bearer ${access_token}`,
          },
      });
    return response.data;