Frage

Ich versuche, Blauimp-Datei hochzuladen in eine MVC-Anwendung und ich "M mit Problemen mit dem Empfang der Dateien in der Post-Aktion (im Gehen von der Multi-Datei-Upload-Funktionalität). Kann jemandem bitte helfen, dies herauszufinden?

Meines Erachtens habe ich den folgenden Code: generasacodicetagpre.

Der JQuery-Code für den Upload von Blauimp-Datei ist folgender: generasacodicetagpre.

und innerhalb des Controllers die folgende Aktionsmethode: generasacodicetagpre.

Ich verwende MVC 3. Wenn in der Aktionsmethode das Argument vom Typ iEnumerable ist, empfängt er NULL, und wenn das Argument vom Typ HttpPostedFileBase ist, empfängt er die Dateien seltsam, und die Aktionmethode funktioniert nicht, wie es angenommen wird.

Jede Art von Hilfe wird sehr geschätzt, danke.

Prost!

War es hilfreich?

Lösung

The SaveFile controller action will be called for each file. So it should look like this:

[HttpPost]
public ActionResult SaveFile(HttpPostedFileBase file)
{
    //some file upload magic

    // return JSON
    return Json(new
    {
        name = "picture.jpg",
        type = "image/jpeg",
        size = 123456789
    });
}

And if you want to handle multiple upload files in the same request you may take a look at the respective section of the documentation.

Andere Tipps

To get the files you could use,

foreach (string inputTagName in Request.Files)
{                
    HttpPostedFileBase file = Request.Files[inputTagName];
}

I know that this is an old issue, but just to point in here. In addition to Darin Dimitrov post - returned json should be in format compatible with jQuery File Upload - which expects array even if one file is transmitted. For example:

        return Json(
            new
            {
                files = new[]{
                                new { 
                                        name = "www.png",
                                        size = "1234567"
                                    }
                              }
            }
        );
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top