MVC3 Valums Ajax File Upload

后端 未结 5 1966
野性不改
野性不改 2020-11-30 22:13

I\'m trying to use valums ajax uploader. http://valums.com/ajax-upload/

I have the following on my page:

var button = $(\'#fileUpload\')[0];
var uplo         


        
5条回答
  •  有刺的猬
    2020-11-30 22:34

    This component is sending an application/octet-stream instead of multipart/form-data which is what the default model binder can work with. So you cannot expect Request.Files to have any value with such a request.

    You will need to manually read the request stream:

    public ActionResult Upload(string qqfile)
    {
        var stream = Request.InputStream;
        var buffer = new byte[stream.Length];
        stream.Read(buffer, 0, buffer.Length);
    
        var path = Server.MapPath("~/App_Data");
        var file = Path.Combine(path, qqfile);
        File.WriteAllBytes(file, buffer);
    
        // TODO: Return whatever the upload control expects as response
    }
    

提交回复
热议问题