Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <script type="text/javascript">
- $(function() {
- $("#dialog").dialog({
- bgiframe: true,
- height: 140,
- modal: true,
- autoOpen: false,
- resizable: false
- })
- });
- </script>
- <div id="dialog" title="Upload files">
- <% using (Html.BeginForm("Upload", "File", FormMethod.Post, new { enctype = "multipart/form-data" }))
- {%>
- <p><input type="file" id="fileUpload" name="fileUpload" size="23"/> </p>
- <p><input type="submit" value="Upload file" /></p>
- <% } %>
- </div>
- <p>
- <label for="image_name">image_name:</label>
- <a href="#" onclick="jQuery('#dialog').dialog('open'); return false">Upload File</a>
- <%= Html.ValidationMessage("image_name", "*") %>
- </p>
- 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)
- {
- foreach (string inputTagName in Request.Files)
- {
- HttpPostedFileBase file = Request.Files[inputTagName];
- if (file.ContentLength > 0)
- {
- string filePath = Path.Combine(HttpContext.Server.MapPath("../Uploads"), Path.GetFileName(file.FileName));
- string filecontent = Path.Combine(HttpContext.Server.MapPath("../Uploads"), Path.GetFileName(file.ContentType));
- image_name = Path.GetFileName(file.FileName);
- img_content = Path.GetFileName(file.ContentType);
- file.SaveAs(filePath);
- }
- }
- AdminImplementation _adminImplementation = new AdminImplementation();
- Boolean isfeature = Convert .ToBoolean(isFeature);
- if (isfeature)
- {
- isFeature = "Featured";
- }
- else
- {
- isFeature = "NotFeatured";
- }
- int i = _adminImplementation.addproduct(category_id, product_name, product_price, product_desc, weight,image_name ,img_content ,available_qty ,isFeature );
- ViewData["succm"] = "Product added successfully";
- return View();
- }
Add Comment
Please, Sign In to add comment