【Ant.designpro】上传图片
一、监听内容
fieldProps
:可以监听并且获取到组件输入的内容
<ProFormUploadButtonlabel={"上传手续图片"}name={"dummyName"}action={"/api/upload_image"} //直连后端接口max={5} //图片上传最大数fieldProps={{onChange:(file)=>{console.log(111111111111111,file.fileList)const fList = []if(file.event){file.fileList.map((value, index)=>{fList.push(value.name)})setFileList(fList)}}}}
/>
二、后端
# 上传文件
@server.route("/api/upload_image", methods=['post'])
def upload_image():file = request.files['file']print("file",file)filename = os.path.join(IMG_DIR,file.filename)print("filename",filename)file.save(filename)return {}