0

I try to use plupload in my asp.net MVC2 project, can I do it? Please help me if it can.

Best regards!

Ryan
  • 3
  • 2

1 Answers1

0

it is same as normal file upload but i like plupload i will use on my project so following codes will work with plupload

[HttpPost]
    public ActionResult Create(FormCollection collection)
    {
        // my project need single file upload so i get the first file
        // also you can write foreach statement to get all files
        HttpPostedFileBase postedFile = Request.Files[0];
        Image image = new Image();
        if (TryUpdateModel(image))
        {
            fRepository.AddImage(image);
            fRepository.Save();

            // Try to save file
            if (postedFile.ContentLength > 0)
            {
                string savePath = Path.Combine(Server.MapPath("~/Content/OtelImages/"), image.ImageID.ToString() +
                                                   Path.GetExtension(postedFile.FileName));
                postedFile.SaveAs(savePath);

                // Path for dbase
                image.Path = Path.Combine("Content/OtelImages/", image.ImageID.ToString() +
                                                   Path.GetExtension(postedFile.FileName));
            }

i didn't change the codes, but if you need any further help please ask, i'll explain

c0demaster
  • 738
  • 6
  • 17
  • 1
    Hi c0demaster, thanks for your help. I already read some previous post about that, but I can not make plupload run in my MVC 2 project. Please give me more details about that. Thank you! – Ryan Aug 23 '11 at 04:25
  • Hi Ryan your welcome, i got this code from my old project i think it would work. But plupload needs ajax interaction so i'll write a code for plupload, it will might be more effective. so please let me know if it works or not cuz i'm out of my desktop comp. i cannot try it – c0demaster Aug 23 '11 at 04:32
  • Hi c0demaster, which library or file need to include to my project? Please help me code the view page. – Ryan Aug 23 '11 at 04:50
  • there is a working example with the mvc platform as i said i can't try it, i'll do when i go to my desktop computer http://stackoverflow.com/questions/4444955/how-to-use-the-plupload-package-with-asp-net-mvc – c0demaster Aug 23 '11 at 09:05