Advertisement
Guest User

Untitled

a guest
Jun 25th, 2019
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.33 KB | None | 0 0
  1. var mt = db.MtoTransparencia.Find(id);
  2.  
  3. if (mt == null)
  4. {
  5. return HttpNotFound();
  6. }
  7.  
  8. var adjunto = new MtoTransparenciaAdjunto
  9. {
  10. MtoTransparenciaId = mt.MtoTransparenciaId,
  11. };
  12. return View(adjunto);
  13.  
  14. @model WebDBT.Models.MtoTransparenciaAdjunto
  15. @{
  16.  
  17. Layout = null;
  18. }
  19.  
  20. @using (@Html.BeginForm("UploadAdjunto", "MtoTransparencia", FormMethod.Post, new { @class = ".FrmUpload" }))
  21. {
  22. @Html.AntiForgeryToken();
  23. @Html.HiddenFor(model => model.MtoTransparenciaId);
  24.  
  25.  
  26. <div class="form-horizontal">
  27. <hr />
  28. @Html.ValidationSummary(true, "", new { @class = "text-danger" })
  29. <div class="form-group">
  30. @Html.LabelFor(model => model.Ruta, htmlAttributes: new { @class = "control-label col-md-2" })
  31. <div class="col-md-10">
  32. @Html.TextBoxFor(model => model.Ruta, "", new { @type = "file", @multiple = "multiple", @name = "file" })
  33. @Html.ValidationMessageFor(model => model.Ruta, "", new { @class = "text-danger" })
  34. </div>
  35. </div>
  36. <div class="form-group">
  37. <div class="col-md-offset-2 col-md-10">
  38. <input type="submit" value="Upload" class="btn btn-primary" />
  39. </div>
  40. </div>
  41. <div class="form-group">
  42. <div class="col-md-offset-2 col-md-10 text-success">
  43. @ViewBag.FileStatus
  44. </div>
  45. </div>
  46. </div>
  47.  
  48.  
  49.  
  50. @section Scripts {
  51. @Scripts.Render("~/bundles/jqueryval")
  52. @Scripts.Render("~/bundles/WEBDBT")
  53. @Scripts.Render("~/Scripts/WebScript/MtoTransparencia.js")
  54. }
  55.  
  56. [ValidateAntiForgeryToken, HttpPost]
  57. public ActionResult UploadAdjunto(HttpPostedFileBase File,MtoTransparenciaAdjunto model)
  58. {
  59. var user = db.MtoUsuarios.Where(u => u.UserName == User.Identity.Name).FirstOrDefault();
  60. if (user == null)
  61. {
  62. RedirectToAction("Index", "Home");
  63. }
  64.  
  65. File = File ?? Request.Files["Ruta"];
  66.  
  67. if (File.ContentLength != 0)
  68. {
  69. string extension = System.IO.Path.GetExtension(File.FileName).ToLower();
  70.  
  71. string[] validFileTypes = { ".xls", ".xlsx", ".csv" };
  72. }
  73. return View();
  74.  
  75. }
  76.  
  77. File = File ?? Request.Files["Ruta"];
  78.  
  79. System.NullReferenceException: 'Referencia a objeto no establecida como instancia de un objeto.'
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement