Am having a MVC
application wherein user uses the fileupload control and upload the file which is having 30 MB or more into the sql db.
am pretty new to MVC arch., so, am sorry,i may ask stupid questions!
Now, customer says that,end users are facing difficulty in uploading many large files, so, he wanted to optimize , by selecting a folder and fetch all those huge files and insert into the sql db.
multi-file-upload-not-userfriendly
The end users say, they don't wanna click on upload browse & but on on multiple times. instead, they will select a folder - which contain all the files they want- and they will click on a single upload button, it will be uploaded/inserted into db. in the above figure, there are 4 file uploads required. but there may be cases that, thee may be 10 file uploads are required. in this case, end user will not be interested in doing this multifile upload , one by one. these files may be having the size of 10 kb to 100 MB size!
Whats the alternative approach to upload multiple files that also has huge size files into db? after several thoughts, am planning to:
1) Zip file file and load the files into a server's shared location and from there, my code will read files one by one and insert into db
but,can anyone please confirm whether this is the correct approach? I need to create a shared drive in the server -say C:\sharedFolder
and then i will prompt the user to browse the multiple files (say file1.txt, file2.xlsx, etc which are having some 40 mb, 50 MB respectively...) and when the click on upload , i will copy the files and dump it into server's sharedfolder location.
what i have tried: I used the fileupload control.
current code in my ABCcontroller.cs file :
[HttpPost]
public ActionResult UploadfilePost(HttpPostedFileBase file)
{
string _path;
try
{
if (file.ContentLength > 0)
{
string _FileName = Path.GetFileName(file.FileName);
_path = Path.Combine(Server.MapPath(@"~/App_Data"), _FileName);
file.SaveAs(_path);
var tempFileName = Path.GetTempFileName();
try
{
using (var streamReader = new StreamReader(_path))
using (var streamWriter = new StreamWriter(tempFileName))
{
// code to further manipulate
}