正在显示
2 个修改的文件
包含
8 行增加
和
2 行删除
@@ -37,7 +37,13 @@ router.post('/upLoadDoc',uploaddemo, async (ctx, next) => { | @@ -37,7 +37,13 @@ router.post('/upLoadDoc',uploaddemo, async (ctx, next) => { | ||
37 | category:category, | 37 | category:category, |
38 | path:'http://localhost:10000/'+ctx.req.file.originalname | 38 | path:'http://localhost:10000/'+ctx.req.file.originalname |
39 | } | 39 | } |
40 | - let attachment = await attachmentModel.create(attachmentData) | 40 | + let oldAttachment = await attachmentModel.findOne({where:{businessId:businessId}}) |
41 | + | ||
42 | + if(oldAttachment){ | ||
43 | + let oldAttachment = await attachmentModel.update({path:'http://localhost:10000/'+ctx.req.file.originalname},{where:{businessId:businessId}}) | ||
44 | + }else{ | ||
45 | + let attachment = await attachmentModel.create(attachmentData) | ||
46 | + } | ||
41 | ctx.response.status= 200; | 47 | ctx.response.status= 200; |
42 | ctx.body = { | 48 | ctx.body = { |
43 | fileUrl:'http://localhost:10000/'+ctx.req.file.originalname | 49 | fileUrl:'http://localhost:10000/'+ctx.req.file.originalname |
@@ -7,7 +7,7 @@ | @@ -7,7 +7,7 @@ | ||
7 | <script src="http://cdn.bootcss.com/jquery/2.0.0/jquery.min.js"></script> | 7 | <script src="http://cdn.bootcss.com/jquery/2.0.0/jquery.min.js"></script> |
8 | </head> | 8 | </head> |
9 | <body> | 9 | <body> |
10 | - <form action="/upload/upLoadDoc?businessId=1&category=1" method="post" enctype="multipart/form-data"> | 10 | + <form action="/upload/upLoadDoc?businessId=0aJeQOYgLAo5yB1mE14Rvzb69V7mpZKD&category=1" method="post" enctype="multipart/form-data"> |
11 | <input type="file" name="file"/> | 11 | <input type="file" name="file"/> |
12 | <input type="text" value="1212" name="class" > | 12 | <input type="text" value="1212" name="class" > |
13 | <input type="submit" value="ok"/> | 13 | <input type="submit" value="ok"/> |
-
请 注册 或 登录 后发表评论