Upload/download pdf files in SQL Server using mvc 2010
I've been learning on my own how to program in c# with mvc 2010 Express, as I've been asked to create an application for the company I work for. The last thing I have to do is allow the users toupload and download a pdf file and I can't find a solution that helps me.
I use SQL Server 2005. The table I want to use is called
Clients. It has an Id as the primary key. Should I create an attribute to store the pdf as a binary file? Or how?
To upload the pdf I have a link in my view that redirects the user to another view (named Upload) with the
id of the client. The controller name is Home, so the user will see something like:
There, I want the user to be able to select the pdf he wants to upload and then click the button to upload it. So the controller will handle it with the
[HttpPost].
To edit a client it was pretty straight forward, as I created Model Views in the folder ViewModels and then passed them to the controller. But how can I pass to the controller both the
id and the pdf file? I need the id to know what user is that. And how can I store the pdf in my table Clients in SQL Server? And then how can I download the pdf? | |||||
|
6
|
This is what i'm using...you should do some changes to adapt it to your requirements.
View:
Controller:
Controller:
View:
Database Table:
To store the files I'm using a Stored Procedure
Model:
|






