我是 ASP.net MVC3 应用程序的新手。 我正在做这个项目,我必须处理 PDF 文件。 我必须能够将 PDF 文件上传到我的文件服务器,并且文件上传后,用户必须能够在同一页面上看到上传文档的预览。 预览必须加载到某些 DIV 或部分 View 中。 我花了很多时间进行研究,但仍然无法得到我需要的东西。 如果有人可以帮助我,我将非常感激。
最佳答案
public class FileUploadController[HttpPost]{
public ActionResult UploadFile(HttpPostedFileBase uploadFile){
//Save file to server
return new FileContentResult(fileContents, contentType);
}
}
@using (Html.BeginForm("UploadFile", "FileUpload", FormMethod.Post, new { enctype = "multipart/form-data" })){
<input type="file" name="uploadFile" id="uploadFile" />
<input type="submit" name="FileUpload" value="Upload" id="FileUpload"/>
}
关于asp.net-mvc-3 - 上传PDF文件并在ASP.net MVC3中预览上传的文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9308546/