Plugin to upload multiple pictures

2

I have the following classes in my project.

Galeria and Fotos

I have ViewModel where I get the data of Galeria and data of Fotos .

When submitting (submit normal, not asynchronous), save Galeria and Fotos with ID of Galeria created.

Everything is working perfectly, however depending on the amount of Images selected the page is stopped and no information of what is happening appears to the user.

I want to implement some Plugin to do this, I researched many but I could not understand how I applied this case to the examples I saw.

Any suggestions and welcome.

    
asked by anonymous 17.05.2014 / 22:46

2 answers

0

A widely used plugin is uploadify . Download the package and have MVC Web in it as it is in this html . The input type file has the name of Filedata that will be the same name rescued in the Action that will receive such photo, and has a variable idAlbum that you can refer to your Album and at the time of recording your photo work with this variable.

Html

@{ Layout = null; }
<!DOCTYPE html>
<html>
<head>
    <meta name="viewport" content="width=device-width" />
    <title>GravarFotos</title>
    <!--Ficaria assim a disposição-->
    <script src="~/Scripts/jquery-2.1.0.js"></script>
    <script src="~/Scripts/jquery.uploadify.js"></script>
    <link href="~/Content/uploadify.css" rel="stylesheet" />
    <!--Fim da diposição-->
</head>
<body>
    <div> 
        <input type="file" name="Filedata" id="Filedata" />
    </div>
    <script>
        var idAlbum = '1';
        $(function () {
            $('#Filedata').uploadify({
                'swf': '/Content/uploadify.swf',
                'uploader': '/Home/GravarFotos',
                'method': 'post',
                'formData': { 'idAlbum': idAlbum }
            });
        });
    </script>
</body>
</html>

Action Code

[HttpGet]
public ActionResult GravarFotos()
{
     return View();
}

[HttpPost]
public String GravarFotos(HttpPostedFileBase Filedata, int? idAlbum)
{
     Filedata.SaveAs(Server.MapPath("~/Fotos/") + Filedata.FileName);
     return "1";
}

There are more items in this plugin that can be configured, as demonstrated in this link .

References

18.05.2014 / 15:38
1

You can use PlUpload , a very good plugin for uploading multiple files!

If the user's browser supports HTML5 it uses, if it does not support, it uses Flash, Silverlight, and finally if it does not support any of these, it uses HTML4 to select the multiple files.

There are several settings available on it, including you can create your own. And it displays individual and global progress bar, and thumbnails too!

There is the possibility of setting up for him to break the file into parts, and to go sending part by part, and on the server he puts it all together. Example to send large files!

Its use is very simple and works in several languages, including a post explaining step by step how to use it with ASP .Net MVC follow the link:

Using Plupload with ASP .Net MVC

We need to help out!

    
13.06.2014 / 17:37