Save to database in ASP.NET MVC

Last post 02-03-2012, 1:09 AM by lasseedsvik. 2 replies.
Sort Posts: Previous Next
  •  02-02-2012, 2:03 AM 72901

    Save to database in ASP.NET MVC

    Hello
     
    I'm trying to upload a file to a database using the entity framework.
     
    How do I modify this:
     
    void Uploader_FileUploaded(object sender, UploaderEventArgs args)
        {
            byte[] data = new byte[args.FileSize];
            using (Stream stream = args.OpenStream())
            {
                
    stream.Read(data, 0, data.Length);
            
    }
        
    }
     
     
    Parameters and so on... And how do I get the filename, size and so on? And is it possible to post directy to the action in the controller?
      
     
    Thanks
    /Lasse 
  •  02-02-2012, 6:16 AM 72909 in reply to 72901

    Re: Save to database in ASP.NET MVC

    Hi Lasse,
     
    You can get the fine name and fine size by the properties below
     
    args.FileName;
    args.FileSize;
     
    Regards,
     
    Ken 
     
  •  02-03-2012, 1:09 AM 72915 in reply to 72909

    Re: Save to database in ASP.NET MVC

    Yes, but do I post directlly to controller, and which parameters should I send? And howto read content as byte-array? 
View as RSS news feed in XML