当前位置 : 主页 > 网页制作 > HTTP/TCP >

OSS上传文件(二)

来源:互联网 收集:自由互联 发布时间:2021-06-16
[HttpPost] public ActionResult ConfirmUpload() { string businessId = Request["businessId"]; string businessType = Request["businessType"]; string itemId = Request["itemId"]; if (string.IsNullOrEmpty(businessId) || string.IsNullOrEmpty(busin

[HttpPost]
public ActionResult ConfirmUpload()
{
string businessId = Request["businessId"];
string businessType = Request["businessType"];
string itemId = Request["itemId"];
if (string.IsNullOrEmpty(businessId) || string.IsNullOrEmpty(businessType) || string.IsNullOrEmpty(itemId))
return Json(new { success = false, content = "缺少关键参数" });
if (Request.Files != null)
{
try
{
for (int i = 0; i < Request.Files.Count; i++)
{
if (Request.Files[i].FileName != "")
{
HttpPostedFileBase file = Request.Files[i];
var steam = file.InputStream;
AliyunOSS.PutObject(bucketName, "不符合项/" + file.FileName, steam);

//写入文件表

 文件路径="相对路径/" +file.FileName

}
}
return Json(new { success = true, content = "" });
}
catch
{
return Json(new { success = false, content = "" });
}
}
return Json(new { success = false, content = "无法读取文件" });

}

上一篇:Knight Moves
下一篇:逻辑思维训练题
网友评论