本文介绍了flow.js上单击上传文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

希望有人能够帮助这一点。

Hopefully someone can help with this.

基本上,我们使用的是NG-流允许拖放上传项目。
我们还利用MVC 4。

Basically, we are using ng-flow https://github.com/flowjs/ng-flow to allow for drag and drop to upload items.We are also using MVC 4.

一切似乎是工作为应,但是,我们想自定义此,让

All seems to be working as should, however, we would like to customize this, so that


  1. 项目被拖入上传框,并存储在范围(像现在一样)

  2. 产品不是物理上载,直到按钮被点击

有什么我们尝试这么远? -

What have we tried so far? :-

在配置中,我们已经禁用了目标,使得它不会立即上传

in the config, we have disabled the target so that it doesn't upload immediately

.config(['flowFactoryProvider', function (flowFactoryProvider) {
flowFactoryProvider.defaults = {
  target: '',
  permanentErrors: [500, 501],
  maxChunkRetries: 1,
  chunkRetryInterval: 5000,
  simultaneousUploads: 1
};

实际的页面上,我们已经创建了一个按钮,与NG单击将通过flow.files

on the actual page, we have created a button, with an ng-click which will pass through the flow.files

<input type="button" value="Click Me" ng-click="uploadme($flow.files)">

在控制器,我们有功能,uploadme,接受流作为paramater。
通过这个paramater循环和后每个文件来上传控制器

in the controller, we have the function, uploadme, that accepts flows as a paramater.Looping through this paramater and post each "file" to the upload controller

$scope.uploadme= function (flows)
{
    angular.forEach(flows, function (flow) {
        var fd = new FormData();
        fd.append("file", flow);
        $http.post("upload", fd, {
            withCredentials: true,
            headers: {'Content-Type': undefined },
            transformRequest: angular.identity
        })
    });

}

MVC控制器,上传。这个被调用,但是,文件始终是空

MVC controller, 'upload'. this get called, however, file is always null

public ActionResult upload(HttpPostedFileBase file)
    {
        if (file.ContentLength > 0)
        {
            var fileName = Path.GetFileName(file.FileName);
            var path = Path.Combine(Server.MapPath("~/App_Data/uploads"), fileName);
            file.SaveAs(path);
        }
        return View();
    } 

有没有,我们失去了一些东西?还是有不同的方式来实现这一目标。

Is there something that we are missing? or is there a different way to achieve this.

推荐答案

设法解决这个...

从div标签删除行

flow-files-submitted="$flow.upload()"

然后的onclick按钮,传递$流入作为paramater

then onclick of a button, pass in $flow in as a paramater

ng-click="InsertItems($flow)"

使用Javascript: -

Javascript:-

$scope.InsertItems = function(e)
{
//Do what you need to do
e.upload();
}

这篇关于flow.js上单击上传文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-22 13:02