CWS MVC Umbraco Starter Member registration and File upload
Hi guys,
The New MVC based starter by Warren B. is a very nice starting point for learning how to do things in Umbraco.
In looking at it I was trying to come up with a way to slightly extent the member registration functionality.
Imagine you'd like to start a "vacancies" page on a website such that users could apply for a job by first registering and next uploading a CV (e.g. as PDF).
I would imagine you could do so by extending the first the member type to also feature a "file upload" property and next also creating the necessary functionality in the "ProfileViewModel" and related.
However, it is there that I lose track of things and don't really know how to start out.
I think I'm nearly there, I have the file uploaded & saved.
However I'm saving the media ID of file to the members upload field, doesn't have the complete link in the admin area.
Code to upload & save:
if (model.CVFile != null)
{
var mediaService = Services.MediaService;
//CreateMedia takes the name of the media you are created, the id of the parent and finally the alias of the MediaType that you want the media to be based on.
var media = mediaService.CreateMedia(model.CVFile.FileName, 1137, "File");
mediaService.Save(media);
media.SetValue("umbracoFile", model.CVFile);
//And then save it similar to the above snippet
mediaService.Save(media);
updateMember.getProperty("CVFile").Value = media.Id;
}
The link in the admin next to the upload field is : "/media/1152" How do I get the full path to the file ?
CWS MVC Umbraco Starter Member registration and File upload
Hi guys,
The New MVC based starter by Warren B. is a very nice starting point for learning how to do things in Umbraco.
In looking at it I was trying to come up with a way to slightly extent the member registration functionality.
Imagine you'd like to start a "vacancies" page on a website such that users could apply for a job by first registering and next uploading a CV (e.g. as PDF).
I would imagine you could do so by extending the first the member type to also feature a "file upload" property and next also creating the necessary functionality in the "ProfileViewModel" and related.
However, it is there that I lose track of things and don't really know how to start out.
Does anybody have an idea?
In relation to the above:
If I add:
To the ProfileViewModel and subsequently add:
To ProfileEdit.cshtml... temporarily ignoring the controller modifications that are necessary.
Then I get this:
Which, although expected, is not really desired. I would expect an upload control of course :)
Hey,
I'm just trying to figure this out as well, did you get anywhere with it?
Thanks,
Kyle
Hi Kyle, Chris
When doing file upload forms in MVC, I've used this.
In the view model:
In the view, just use the standard HTML file input:
Make sure also to have this on your form (as an extra parameter passed to the Html.BeginForm or Html.BeginUmbracoForm) too:
And then in the post action for the controller you can access the file like this.
Hope that helps - for the bit in comments above (the associating of the file with the member) looks like this thread will help.
Andy
Hi Andy,
I think I'm nearly there, I have the file uploaded & saved.
However I'm saving the media ID of file to the members upload field, doesn't have the complete link in the admin area.
Code to upload & save:
The link in the admin next to the upload field is : "/media/1152" How do I get the full path to the file ?
Kind Regards,
Kyle
is working on a reply...