C# 页面不保存 PDF 或 PPT

C# Page doesn't save PDF or PPT

我在上传文件时遇到问题。我需要用户上传 ppt、pdf、doc、png、jpg 等,但如果我尝试它只会保存 doc 和 png。有人知道为什么吗?

 public void uploadFile(ACFilesModel picture, Bestanden actualiteiten)
    {
        string path = "";
        string VirPath = "";
        for (int i = 0; i < picture.Files.Count; i++)
        {
            if ((picture.Files[i] != null) && (picture.Files[i].ContentLength > 0) && (picture.Files[i].ContentLength < 2097152))
            {
                var fileName = Path.GetFileName(picture.Files[i].FileName);

                path = Path.Combine(System.Web.HttpContext.Current.Server.MapPath(@"/LGSite/Site/Images/" + fileName));
                picture.Files[i].SaveAs(path);
                ViewBag.path = path;
                VirPath = path.Replace(path, @"/Images/" + fileName);
                db.Bestanden.Add(new Bestanden { ContentType = VirPath, BsOmschrijving = picture.OmschrijvingBS[i], Nieuws_ID = actualiteiten.Nieuws.ID });
                db.SaveChanges();
            }
            else
            {
                ModelState.AddModelError("ContentType", "File is te groot!");
            }
        }
    }

希望能帮到你!

有史以来最愚蠢的错误。 我不得不改变路径。服务器找不到正确的路径(因为它不存在)但现在它可以工作了。 愚蠢的是它确实适用于 doc 和 PNG。所以我不知道为什么会这样。