This question is locked. New answers and comments are not allowed.
Hi there quys
Need some help, know what I am doing might not be the correct solution and it will end up biting me where I don't want it to....
Right here is the scenario, using a standard wired up create view to a client model. This model contains a field that holds the path to the client photo, do not want to store the photo as a blob in the db, due to requirements issues.
I am using the telerik uploader ofcourse, based on the standard examples posted, I need to get the uploaded path back into the model, the uploader doesn't support binding right or am I just missing it somewhere? here is the view code:
This is on a create view, take it the same question goes for the edit part as well, note the above is still just testing and evaluating available options and yep, a bit new to mvc.
Need some help, know what I am doing might not be the correct solution and it will end up biting me where I don't want it to....
Right here is the scenario, using a standard wired up create view to a client model. This model contains a field that holds the path to the client photo, do not want to store the photo as a blob in the db, due to requirements issues.
I am using the telerik uploader ofcourse, based on the standard examples posted, I need to get the uploaded path back into the model, the uploader doesn't support binding right or am I just missing it somewhere? here is the view code:
@(Html.Telerik().Upload() .Name("clientUpload") .Async(async => async .Save("UploadFile", "Upload") .Remove("Remove", "Upload") ) .Multiple(false) .ClientEvents(events => events .OnSuccess("onSuccess") ) )The controler:<script type="text/javascript"> function onSuccess(e) { // Array with information about the uploaded files var files = e.files; if (e.operation == "upload") { document.getElementById("photopath").value = e.response.status; } return false; } </script>
public ActionResult UploadFile(IEnumerable<HttpPostedFileBase> clientUpload) { string destinationPath = ""; foreach (var file in clientUpload) { var filename = Path.GetFileName(file.FileName); destinationPath = Path.Combine(Server.MapPath("~/App_Data/client_Up"), filename); file.SaveAs(destinationPath); TempData["UploadedPath"] = destinationPath; } return Json(new { status = destinationPath }, "text/plain"); } public ActionResult Remove(string[] fileNames) { foreach (var fullName in fileNames) { var fileName = Path.GetFileName(fullName); var deletePath = Path.Combine(Server.MapPath("~/App_Data/Client_Up"), fileName); if (System.IO.File.Exists(deletePath)) { System.IO.File.Delete(deletePath); } } return Content(""); }
This is on a create view, take it the same question goes for the edit part as well, note the above is still just testing and evaluating available options and yep, a bit new to mvc.