0

I am developing an application where it requires User Profile creation. Though MVC 4 templates has a built-in option for authorization and authentication. But I want to save some more info of users. So I created User Profile table having USER_ID primary attribute and some more attributes. However I am not saving user profile picture in same table with user data. I am saving it to another table called File_master having file ID as primary attribute.

What I created so far is a User Controller , then it created all views for CRUD ops. Here I created a new Field for profile picture with a submit button. For submitting this selected image to db I created another Action method on the same controller.

Now scenario is, Whenever I Click upload image button, action method create is being hit, where I suppose action Method upload should get hit.

How to solve this issue? Lil help with some sample will appreciated.

Mayur A Muley
  • 51
  • 1
  • 12

1 Answers1

0

It seems that the problem is from the View which is responsible for uploading image. Check the action of its form and ensure that it is linked to the action method you want.

And about the rest of the work, take a look at the following link to see how to store images in database

https://stackoverflow.com/questions/17966503/how-to-insert-an-image-into-sql-server-database/

Community
  • 1
  • 1
Amin Saqi
  • 18,549
  • 7
  • 50
  • 70
  • It didn't worked for me! @AminSaghi. I think the problem is One cannot have more than one form on a strongly typed bonded view. Because when ever I Am clicking upload ( `` ) button its hitting create action instead on upload action specified in `@.Html.BeginForm("ActionName","ControllerName", new { multipartData = ... }` Something is wrong or It actually does not accept more than one form element on a view. – Mayur A Muley Mar 18 '15 at 09:59
  • @MayurAMuley It is right for partial views - you can not have to model binded forms in a single partial view. but you can have view, with several partial views each of which has its won model and form... – Amin Saqi Mar 18 '15 at 10:17
  • @AmitSaghi Sir i tried both ways. I created a strongly typed binded view lets name it as ParentView, then I created partial view ChildView with its own form and post method. Now the issue arises when I click on upload button on ChildView (which is rendered on parent view, again which have its own form binded to some model) it is hitting to action method created for ParentView, not the action method created for child view. How to solve this issue? – Mayur A Muley Mar 19 '15 at 12:38