Guest User

Untitled

a guest
Apr 20th, 2018
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.02 KB | None | 0 0
  1. <script type="text/javascript">
  2. $(function() {
  3. $("#dialog").dialog({
  4. bgiframe: true,
  5. height: 140,
  6. modal: true,
  7. autoOpen: false,
  8. resizable: false
  9. })
  10. });
  11.  
  12. </script>
  13.  
  14. <div id="dialog" title="Upload files">
  15. <% using (Html.BeginForm("Upload", "File", FormMethod.Post, new { enctype = "multipart/form-data" }))
  16. {%>
  17. <p><input type="file" id="fileUpload" name="fileUpload" size="23"/> </p>
  18. <p><input type="submit" value="Upload file" /></p>
  19. <% } %>
  20. </div>
  21.  
  22. <p>
  23. <label for="image_name">image_name:</label>
  24. <a href="#" onclick="jQuery('#dialog').dialog('open'); return false">Upload File</a>
  25.  
  26. <%= Html.ValidationMessage("image_name", "*") %>
  27. </p>
  28.  
  29. public ActionResult AddProduct(int category_id, string product_name, float product_price, string product_desc, string weight, string image_name, string img_content, string available_qty, string isFeature)
  30. {
  31.  
  32. foreach (string inputTagName in Request.Files)
  33. {
  34. HttpPostedFileBase file = Request.Files[inputTagName];
  35. if (file.ContentLength > 0)
  36. {
  37. string filePath = Path.Combine(HttpContext.Server.MapPath("../Uploads"), Path.GetFileName(file.FileName));
  38. string filecontent = Path.Combine(HttpContext.Server.MapPath("../Uploads"), Path.GetFileName(file.ContentType));
  39.  
  40. image_name = Path.GetFileName(file.FileName);
  41. img_content = Path.GetFileName(file.ContentType);
  42.  
  43. file.SaveAs(filePath);
  44. }
  45. }
  46.  
  47. AdminImplementation _adminImplementation = new AdminImplementation();
  48.  
  49. Boolean isfeature = Convert .ToBoolean(isFeature);
  50.  
  51. if (isfeature)
  52. {
  53. isFeature = "Featured";
  54. }
  55. else
  56. {
  57. isFeature = "NotFeatured";
  58. }
  59.  
  60.  
  61. int i = _adminImplementation.addproduct(category_id, product_name, product_price, product_desc, weight,image_name ,img_content ,available_qty ,isFeature );
  62.  
  63. ViewData["succm"] = "Product added successfully";
  64. return View();
  65. }
Add Comment
Please, Sign In to add comment