Esempio n. 1
0
        public JsonResult UploadPurSupplierCertificateFile(HttpPostedFileBase file)
        {
            var FailResult = new { Result = "FAIL" };

            if (file != null)
            {
                if (file.ContentLength > 0)
                {
                    FileAttatchData data = JsonConvert.DeserializeObject <FileAttatchData>(Request.Params["fileAttachData"]);
                    //待加入验证文件名称逻辑:
                    if (data == null)
                    {
                        return(Json(FailResult));
                    }
                    string extensionName = System.IO.Path.GetExtension(file.FileName);
                    string fileName      = String.Format("{0}{1}{2}", data.SupplierId, data.EligibleCertificate, extensionName);
                    string fullFileName  = Path.Combine(this.CombinedFilePath(FileLibraryKey.FileLibrary, FileLibraryKey.PurSupplierCertificate), fileName);
                    file.DeleteExistFile(fullFileName).SaveAs(fullFileName);
                    return(Json(new { Result = "OK", FileName = fileName }));
                }
            }
            return(Json(FailResult));
        }